@fbp/evaluator 1.9.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cycles.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Edge } from '@fbp/types';
1
+ import type { Edge } from '@fbp/spec';
2
2
  /**
3
3
  * Find a dependency cycle among the named nodes, the way pgpm's dependency
4
4
  * resolver does: walk upstream depth-first, keeping the nodes still being
@@ -6,4 +6,5 @@ export declare const constNumberDef: NodeDefinitionWithImpl;
6
6
  export declare const addDef: NodeDefinitionWithImpl;
7
7
  export declare const multiplyDef: NodeDefinitionWithImpl;
8
8
  export declare const subtractDef: NodeDefinitionWithImpl;
9
+ export declare const divideDef: NodeDefinitionWithImpl;
9
10
  export declare const mathDefinitions: NodeDefinitionWithImpl[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mathDefinitions = exports.subtractDef = exports.multiplyDef = exports.addDef = exports.constNumberDef = void 0;
3
+ exports.mathDefinitions = exports.divideDef = exports.subtractDef = exports.multiplyDef = exports.addDef = exports.constNumberDef = void 0;
4
4
  /**
5
5
  * Math node definitions with implementations for testing.
6
6
  */
@@ -61,9 +61,28 @@ exports.subtractDef = {
61
61
  difference: (inputs.a ?? 0) - (inputs.b ?? 0)
62
62
  })
63
63
  };
64
+ exports.divideDef = {
65
+ context: 'js',
66
+ name: 'divide',
67
+ category: 'math',
68
+ icon: 'divide',
69
+ inputs: [
70
+ { name: 'a', type: 'number' },
71
+ { name: 'b', type: 'number' }
72
+ ],
73
+ outputs: [{ name: 'quotient', type: 'number' }],
74
+ description: 'Divides a by b',
75
+ impl: (inputs) => {
76
+ const divisor = inputs.b ?? 1;
77
+ if (divisor === 0)
78
+ throw new Error('math:divide cannot divide by zero');
79
+ return { quotient: (inputs.a ?? 0) / divisor };
80
+ }
81
+ };
64
82
  exports.mathDefinitions = [
65
83
  exports.constNumberDef,
66
84
  exports.addDef,
67
85
  exports.multiplyDef,
68
- exports.subtractDef
86
+ exports.subtractDef,
87
+ exports.divideDef
69
88
  ];
package/definitions/ui.js CHANGED
@@ -24,9 +24,9 @@ function coerceValue(value, valueType) {
24
24
  }
25
25
  // Boundary node definitions for graph inputs/outputs
26
26
  exports.graphInputDef = {
27
- context: 'core',
27
+ context: 'js',
28
28
  name: 'graphInput',
29
- category: 'graph',
29
+ category: 'core',
30
30
  icon: 'arrow-right',
31
31
  inputs: [],
32
32
  outputs: [{ name: 'value', type: 'any' }],
@@ -38,9 +38,9 @@ exports.graphInputDef = {
38
38
  impl: (_inputs, props) => ({ value: coerceValue(props?.value ?? props?.default, props?.valueType ?? 'any') })
39
39
  };
40
40
  exports.graphOutputDef = {
41
- context: 'core',
41
+ context: 'js',
42
42
  name: 'graphOutput',
43
- category: 'graph',
43
+ category: 'core',
44
44
  icon: 'arrow-left',
45
45
  inputs: [{ name: 'value', type: 'any' }],
46
46
  outputs: [],
@@ -51,9 +51,9 @@ exports.graphOutputDef = {
51
51
  impl: (inputs, props) => ({ value: coerceValue(inputs.value, props?.valueType ?? 'any') })
52
52
  };
53
53
  exports.graphPropDef = {
54
- context: 'core',
54
+ context: 'js',
55
55
  name: 'graphProp',
56
- category: 'graph',
56
+ category: 'core',
57
57
  icon: 'settings',
58
58
  inputs: [],
59
59
  outputs: [{ name: 'value', type: 'any' }],
@@ -58,9 +58,28 @@ export const subtractDef = {
58
58
  difference: (inputs.a ?? 0) - (inputs.b ?? 0)
59
59
  })
60
60
  };
61
+ export const divideDef = {
62
+ context: 'js',
63
+ name: 'divide',
64
+ category: 'math',
65
+ icon: 'divide',
66
+ inputs: [
67
+ { name: 'a', type: 'number' },
68
+ { name: 'b', type: 'number' }
69
+ ],
70
+ outputs: [{ name: 'quotient', type: 'number' }],
71
+ description: 'Divides a by b',
72
+ impl: (inputs) => {
73
+ const divisor = inputs.b ?? 1;
74
+ if (divisor === 0)
75
+ throw new Error('math:divide cannot divide by zero');
76
+ return { quotient: (inputs.a ?? 0) / divisor };
77
+ }
78
+ };
61
79
  export const mathDefinitions = [
62
80
  constNumberDef,
63
81
  addDef,
64
82
  multiplyDef,
65
- subtractDef
83
+ subtractDef,
84
+ divideDef
66
85
  ];
@@ -21,9 +21,9 @@ function coerceValue(value, valueType) {
21
21
  }
22
22
  // Boundary node definitions for graph inputs/outputs
23
23
  export const graphInputDef = {
24
- context: 'core',
24
+ context: 'js',
25
25
  name: 'graphInput',
26
- category: 'graph',
26
+ category: 'core',
27
27
  icon: 'arrow-right',
28
28
  inputs: [],
29
29
  outputs: [{ name: 'value', type: 'any' }],
@@ -35,9 +35,9 @@ export const graphInputDef = {
35
35
  impl: (_inputs, props) => ({ value: coerceValue(props?.value ?? props?.default, props?.valueType ?? 'any') })
36
36
  };
37
37
  export const graphOutputDef = {
38
- context: 'core',
38
+ context: 'js',
39
39
  name: 'graphOutput',
40
- category: 'graph',
40
+ category: 'core',
41
41
  icon: 'arrow-left',
42
42
  inputs: [{ name: 'value', type: 'any' }],
43
43
  outputs: [],
@@ -48,9 +48,9 @@ export const graphOutputDef = {
48
48
  impl: (inputs, props) => ({ value: coerceValue(inputs.value, props?.valueType ?? 'any') })
49
49
  };
50
50
  export const graphPropDef = {
51
- context: 'core',
51
+ context: 'js',
52
52
  name: 'graphProp',
53
- category: 'graph',
53
+ category: 'core',
54
54
  icon: 'settings',
55
55
  inputs: [],
56
56
  outputs: [{ name: 'value', type: 'any' }],
package/esm/evaluate.js CHANGED
@@ -1,25 +1,5 @@
1
- import { derivePorts, derivePropDefinitions, isRef, joinPath, parsePath, resolveRef } from '@fbp/spec';
1
+ import { assertTypes, definitionKey, derivePorts, derivePropDefinitions, GRAPH_INPUT, GRAPH_OUTPUT, GRAPH_PROP, boundaryName, hoistDefinitions, isLiteral, isRef, joinPath, parsePath, plainValue, resolveRef, SUBNET, typeKey, unwiredInput } from '@fbp/spec';
2
2
  import { findCycle, formatCycle } from './cycles';
3
- /**
4
- * Build a definition map key from context, category, and name.
5
- */
6
- function defKey(context, category, name) {
7
- return `${context}:${category}:${name}`;
8
- }
9
- /**
10
- * Parse a node type (e.g., 'math:add' or 'const/string') into [category, name].
11
- * Colon is the canonical separator (category:name); slash is checked as fallback
12
- * for legacy graph files. Boundary nodes (no separator) default to ['core', type].
13
- */
14
- function parseTaskIdentifier(type) {
15
- const colonIdx = type.indexOf(':');
16
- if (colonIdx !== -1)
17
- return [type.slice(0, colonIdx), type.slice(colonIdx + 1)];
18
- const slashIdx = type.indexOf('/');
19
- if (slashIdx !== -1)
20
- return [type.slice(0, slashIdx), type.slice(slashIdx + 1)];
21
- return ['core', type];
22
- }
23
3
  /**
24
4
  * Evaluate a graph starting from the specified output node/port.
25
5
  * Uses lazy evaluation - only evaluates nodes that are needed for the output.
@@ -28,40 +8,102 @@ function parseTaskIdentifier(type) {
28
8
  * @param graph - The graph to evaluate
29
9
  * @param options - Evaluation options including definitions, output node/port, and external inputs
30
10
  * @returns Promise resolving to the value at the specified output port
11
+ * @throws before anything runs if a node type is not `category:name`, names no
12
+ * known definition, or two definitions share an identity
31
13
  */
32
14
  export async function evaluate(graph, options) {
33
- const outputs = await openGraph(graph, options, [])(options.outputNode);
15
+ // One definition table: the graph's own (nested ones hoisted into it) beside the host's.
16
+ const root = hoistDefinitions(graph);
17
+ const host = hoistDefinitions({ nodes: [], edges: [], definitions: options.definitions }).definitions;
18
+ assertTypes(root, { definitions: host });
19
+ // A stored definition with no graph only describes a node, so it never replaces one that can run.
20
+ const supplied = new Set(host.map(definitionKey));
21
+ const stored = (root.definitions ?? []).filter(d => !supplied.has(definitionKey(d)));
22
+ const definitions = stored.length ? [...host, ...stored] : host;
23
+ const outputs = await openGraph(root, { ...options, definitions }, [])(options.outputNode);
34
24
  return outputs[options.outputPort];
35
25
  }
36
26
  /**
37
27
  * A `{ ref }` to a sibling node's value is a dependency, like an edge.
38
28
  * `scopePath` is where `nodes` live, so absolute references are recognised too.
29
+ *
30
+ * A reference held anywhere inside an inline subnet is a dependency of that subnet: to produce
31
+ * its outputs the subnet reads what its inner nodes refer to. So an inner node that refers to
32
+ * the subnet enclosing it, or to a sibling fed by that subnet, is a cycle like any other.
39
33
  */
40
- export function refEdges(nodes, scopePath = []) {
34
+ export function refEdges(nodes, scopePath = [], wiring) {
41
35
  const names = new Set(nodes.map(n => n.name));
42
36
  const scope = joinPath(scopePath);
43
37
  const edges = [];
44
- for (const node of nodes) {
45
- for (const prop of node.props ?? []) {
38
+ const find = (segments) => {
39
+ if (segments.length <= scopePath.length || scopePath.some((part, i) => segments[i] !== part))
40
+ return undefined;
41
+ let level = nodes;
42
+ let found;
43
+ for (const part of segments.slice(scopePath.length)) {
44
+ found = level.find(n => n.name === part);
45
+ if (!found)
46
+ return undefined;
47
+ level = found.nodes ?? [];
48
+ }
49
+ return found;
50
+ };
51
+ // The siblings a reference reads. A `.prop` reference reads whatever that prop refers to, wired or not.
52
+ const follow = (value, from, seen) => {
53
+ if (!isRef(value))
54
+ return [];
55
+ let target;
56
+ try {
57
+ target = resolveRef(joinPath(from), value.ref);
58
+ }
59
+ catch {
60
+ return [];
61
+ }
62
+ const segments = parsePath(target.path);
63
+ const owner = segments.slice(0, -1);
64
+ if (target.prop === undefined) {
65
+ const sibling = segments[segments.length - 1];
66
+ return sibling !== undefined && names.has(sibling) && joinPath(owner) === scope ? [sibling] : [];
67
+ }
68
+ const key = `${target.path}.${target.prop}`;
69
+ if (seen.includes(key))
70
+ return [];
71
+ return follow(find(segments)?.props?.find(p => p.name === target.prop)?.value, owner, [...seen, key]);
72
+ };
73
+ const collect = (holder, holderScope, dependent, wires, context) => {
74
+ for (const prop of holder.props ?? []) {
46
75
  if (!isRef(prop.value))
47
76
  continue;
48
- let target;
49
- try {
50
- target = resolveRef(scope, prop.value.ref);
51
- }
52
- catch {
77
+ // A typed value on an input that is wired is never read, unless the type also declares a prop of that name.
78
+ if (wiring && holder.type !== SUBNET &&
79
+ wires.some(wire => wire.dst.node === holder.name && wire.dst.port === prop.name) &&
80
+ !wiring.declaresProp(holder.context || context, holder.type, prop.name))
53
81
  continue;
54
- }
55
- const segments = parsePath(target.path);
56
- const sibling = segments[segments.length - 1];
57
- if (target.prop === undefined && sibling !== undefined && names.has(sibling) &&
58
- joinPath(segments.slice(0, -1)) === scope) {
59
- edges.push({ src: { node: sibling, port: 'value' }, dst: { node: node.name, port: prop.name } });
82
+ for (const sibling of follow(prop.value, holderScope, [])) {
83
+ edges.push({ src: { node: sibling, port: 'value' }, dst: { node: dependent, port: prop.name } });
60
84
  }
61
85
  }
62
- }
86
+ if (holder.type !== SUBNET)
87
+ return;
88
+ for (const child of holder.nodes ?? []) {
89
+ collect(child, [...holderScope, holder.name], dependent, holder.edges ?? [], holder.context || context);
90
+ }
91
+ };
92
+ for (const node of nodes)
93
+ collect(node, scopePath, node.name, wiring?.edges ?? [], wiring?.context ?? '');
63
94
  return edges;
64
95
  }
96
+ /** `Wiring` for a scope, answered from its definitions. */
97
+ export function wiringOf(edges, context, definitions) {
98
+ return {
99
+ edges,
100
+ context,
101
+ declaresProp: (ctx, type, prop) => {
102
+ const definition = definitions.get(typeKey(ctx, type));
103
+ return !definition || (definition.props ?? []).some(def => def.name === prop);
104
+ }
105
+ };
106
+ }
65
107
  /**
66
108
  * @param assetPath - definition keys of the digital assets being evaluated,
67
109
  * outermost first, so an asset that contains itself throws instead of
@@ -69,14 +111,14 @@ export function refEdges(nodes, scopePath = []) {
69
111
  */
70
112
  function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
71
113
  const { inputs = {}, props = {}, absent } = options;
72
- // Definitions stored in the graph (converted subnets) join the ones passed in, for this graph and everything inside it.
73
- // A stored definition with no graph only describes a node, so it never replaces one that can run.
74
- const supplied = new Set(options.definitions.map(d => defKey(d.context, d.category ?? 'core', d.name)));
75
- const stored = (graph.definitions ?? []).filter(d => d.graph || !supplied.has(defKey(d.context, d.category ?? 'core', d.name)));
76
- const definitions = stored.length ? [...options.definitions, ...stored] : options.definitions;
114
+ const { definitions } = options;
77
115
  // Reject cycles up front, as the validator and the SQL gate do: pulling
78
116
  // through a loop would otherwise recurse until the stack overflows.
79
- const cycle = findCycle(graph.nodes.map(n => n.name), [...graph.edges, ...refEdges(graph.nodes, scopePath)]);
117
+ const defMap = new Map();
118
+ for (const def of definitions) {
119
+ defMap.set(definitionKey(def), def);
120
+ }
121
+ const cycle = findCycle(graph.nodes.map(n => n.name), [...graph.edges, ...refEdges(graph.nodes, scopePath, wiringOf(graph.edges, graph.context || '', defMap))]);
80
122
  if (cycle) {
81
123
  throw new Error(`Graph "${graph.name}" contains a cycle: ${formatCycle(cycle)}`);
82
124
  }
@@ -85,10 +127,6 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
85
127
  for (const node of graph.nodes) {
86
128
  nodeMap.set(node.name, node);
87
129
  }
88
- const defMap = new Map();
89
- for (const def of definitions) {
90
- defMap.set(defKey(def.context, def.category ?? 'core', def.name), def);
91
- }
92
130
  // Graph-level context used as default for node lookups
93
131
  const graphContext = graph.context || '';
94
132
  // Build edge lookup: destination node -> destination port -> edges (in array order)
@@ -110,9 +148,12 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
110
148
  /**
111
149
  * Resolve a prop value: a `{ ref }` takes the value of the node it points at
112
150
  * (its `value` output, or the named prop for a '.prop' reference). The target
113
- * is in this scope or one that encloses it.
151
+ * is in this scope or one that encloses it. A `{ literal }` is its content,
152
+ * verbatim.
114
153
  */
115
154
  async function resolve(value, holder, chain = []) {
155
+ if (isLiteral(value))
156
+ return value.literal;
116
157
  if (!isRef(value))
117
158
  return value;
118
159
  const target = resolveRef(joinPath(scopePath), value.ref);
@@ -158,10 +199,8 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
158
199
  }
159
200
  // Handle system nodes (graphInput, graphOutput, graphProp)
160
201
  // System nodes are identified by their type name — reserved, no definition lookup needed
161
- if (node.type === 'graphInput') {
162
- // Get the port name from the portName property
163
- const portNameProp = node.props?.find(p => p.name === 'portName');
164
- const inputName = portNameProp?.value || nodeName;
202
+ if (node.type === GRAPH_INPUT) {
203
+ const inputName = boundaryName(node);
165
204
  // A wired input whose arm was not taken stays dark, default or not, as it would in the flat graph.
166
205
  if (absent?.has(inputName)) {
167
206
  cache.set(nodeName, {});
@@ -171,25 +210,23 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
171
210
  let value = inputs[inputName];
172
211
  if (value === undefined) {
173
212
  const defaultProp = node.props?.find(p => p.name === 'default');
174
- value = defaultProp?.value;
213
+ value = plainValue(defaultProp?.value);
175
214
  }
176
215
  const result = { value };
177
216
  cache.set(nodeName, result);
178
217
  return result;
179
218
  }
180
- if (node.type === 'graphProp') {
181
- // Get the prop name from the propName property
182
- const propNameProp = node.props?.find(p => p.name === 'propName');
183
- const propName = propNameProp?.value || nodeName;
219
+ if (node.type === GRAPH_PROP) {
220
+ const propName = boundaryName(node);
184
221
  let value = props[propName];
185
222
  if (value === undefined) {
186
- value = node.props?.find(p => p.name === 'default')?.value;
223
+ value = plainValue(node.props?.find(p => p.name === 'default')?.value);
187
224
  }
188
225
  const result = { value };
189
226
  cache.set(nodeName, result);
190
227
  return result;
191
228
  }
192
- if (node.type === 'graphOutput') {
229
+ if (node.type === GRAPH_OUTPUT) {
193
230
  // graphOutput is a pass-through: evaluate its upstream 'value' input
194
231
  const portEdges = edgesByDst.get(nodeName);
195
232
  const edges = portEdges?.get('value') ?? [];
@@ -207,12 +244,11 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
207
244
  cache.set(nodeName, result);
208
245
  return result;
209
246
  }
210
- // Handle subnet nodes (type: 'subnet' with inline nodes/edges)
211
- if (node.type === 'subnet' && node.nodes) {
247
+ // Handle subnet nodes (inline nodes/edges)
248
+ if (node.type === SUBNET) {
212
249
  // The interface is derived from the boundary nodes inside the subnet.
213
- const derived = derivePorts(node);
214
- const inputPorts = node.inputs ?? derived.inputs;
215
- const outputPorts = node.outputs ?? derived.outputs;
250
+ const children = node.nodes ?? [];
251
+ const { inputs: inputPorts, outputs: outputPorts } = derivePorts(node);
216
252
  // Collect inputs for the subnet by evaluating upstream nodes
217
253
  const subnetInputs = {};
218
254
  const absentInputs = new Set();
@@ -232,6 +268,14 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
232
268
  }
233
269
  }
234
270
  }
271
+ // An unwired input takes the subnet's prop of the same name; the graphInput's default comes after.
272
+ for (const inputPort of inputPorts) {
273
+ if (inputPort.multi || (subnetPortEdges?.get(inputPort.name) ?? []).length > 0)
274
+ continue;
275
+ const stored = unwiredInput(node, inputPort.name);
276
+ if (stored !== undefined)
277
+ subnetInputs[inputPort.name] = await resolve(stored, nodeName);
278
+ }
235
279
  // Promoted parameters: the value set on the subnet node, else the graphProp's default.
236
280
  const subnetProps = {};
237
281
  for (const propDef of derivePropDefinitions(node)) {
@@ -241,10 +285,10 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
241
285
  }
242
286
  }
243
287
  // One evaluation of the inner graph serves every output port.
244
- const pull = openGraph({ name: `${nodeName}_subnet`, context: node.context || graphContext || undefined, nodes: node.nodes, edges: node.edges ?? [] }, { definitions, inputs: subnetInputs, props: subnetProps, absent: absentInputs }, assetPath, [...scopePath, nodeName], scope);
288
+ const pull = openGraph({ name: `${nodeName}_subnet`, context: node.context || graphContext || undefined, nodes: children, edges: node.edges ?? [] }, { definitions, inputs: subnetInputs, props: subnetProps, absent: absentInputs }, assetPath, [...scopePath, nodeName], scope);
245
289
  const subnetOutputs = {};
246
290
  for (const outputPort of outputPorts) {
247
- const outputBoundaryNode = node.nodes.find(n => n.type === 'graphOutput' && n.props?.find(p => p.name === 'portName')?.value === outputPort.name);
291
+ const outputBoundaryNode = children.find(n => n.type === GRAPH_OUTPUT && boundaryName(n) === outputPort.name);
248
292
  if (!outputBoundaryNode) {
249
293
  throw new Error(`Output boundary node not found for port: ${outputPort.name}`);
250
294
  }
@@ -257,8 +301,7 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
257
301
  }
258
302
  // Get the definition for this node — resolve context from node override or graph default
259
303
  const nodeContext = node.context || graphContext;
260
- const [nodeCategory, nodeDefName] = parseTaskIdentifier(node.type);
261
- const key = defKey(nodeContext, nodeCategory, nodeDefName);
304
+ const key = typeKey(nodeContext, node.type);
262
305
  const definition = defMap.get(key);
263
306
  if (!definition) {
264
307
  throw new Error(`No definition found for node: ${nodeContext}:${node.type}`);
@@ -341,6 +384,19 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
341
384
  }
342
385
  }
343
386
  }
387
+ // Unwired: the node's prop of the same name, else the definition's default for it. Read once
388
+ // the wires are known to have arrived, so a node on an arm not taken resolves nothing.
389
+ const ports = [...(definition.inputs ?? []), ...(definition.graph ? derivePorts(definition.graph).inputs : [])];
390
+ const multi = new Set(ports.filter(port => port.multi).map(port => port.name));
391
+ for (const port of new Set(ports.map(port => port.name))) {
392
+ if (multi.has(port))
393
+ continue;
394
+ if ((portEdges?.get(port) ?? []).length > 0)
395
+ continue;
396
+ const stored = unwiredInput(node, port, definition.props);
397
+ if (stored !== undefined)
398
+ nodeInputs[port] = await resolve(stored, nodeName);
399
+ }
344
400
  // Get props from node instance (override definition defaults)
345
401
  const nodeProps = {};
346
402
  if (definition.props) {
@@ -361,13 +417,12 @@ function openGraph(graph, options, assetPath, scopePath = [], parentScope) {
361
417
  }
362
418
  const assetGraph = definition.graph;
363
419
  // One evaluation of the asset's graph serves every output port.
364
- const pull = openGraph({ name: `${nodeName}_asset`, context: assetGraph.context, nodes: assetGraph.nodes, edges: assetGraph.edges, definitions: assetGraph.definitions }, { definitions, inputs: nodeInputs, props: nodeProps, absent: absentInputs }, [...assetPath, key]);
420
+ const pull = openGraph({ name: `${nodeName}_asset`, context: assetGraph.context || definition.context, nodes: assetGraph.nodes, edges: assetGraph.edges }, { definitions, inputs: nodeInputs, props: nodeProps, absent: absentInputs }, [...assetPath, key]);
365
421
  const assetOutputs = {};
366
- for (const outputBoundaryNode of assetGraph.nodes.filter(n => n.type === 'graphOutput')) {
367
- const portNameProp = outputBoundaryNode.props?.find(p => p.name === 'portName');
422
+ for (const outputBoundaryNode of assetGraph.nodes.filter(n => n.type === GRAPH_OUTPUT)) {
368
423
  const result = await pull(outputBoundaryNode.name);
369
424
  if ('value' in result)
370
- assetOutputs[portNameProp?.value || outputBoundaryNode.name] = result.value;
425
+ assetOutputs[boundaryName(outputBoundaryNode)] = result.value;
371
426
  }
372
427
  cache.set(nodeName, assetOutputs);
373
428
  return assetOutputs;
package/esm/index.js CHANGED
@@ -3,6 +3,6 @@ export { evaluate } from './evaluate';
3
3
  export { validateGraph } from './validate';
4
4
  // Re-export node definitions for convenience
5
5
  export { constBooleanDef, constStringDef, coreDefinitions, flowBranchDef, flowCoerceDef, flowFilterDef, flowForEachDef, flowGuardDef, flowMergeDef, flowSwitchDef, jsonMergeDef, jsonObjectDef, jsonSelectDef, jsonSplitDef, stringConcatDef, stringTemplateDef } from './definitions/core';
6
- export { addDef, constNumberDef, mathDefinitions, multiplyDef, subtractDef } from './definitions/math';
6
+ export { addDef, constNumberDef, divideDef, mathDefinitions, multiplyDef, subtractDef } from './definitions/math';
7
7
  export { graphqlRequestDef, netDefinitions } from './definitions/net';
8
8
  export { buttonDef, formDef, graphInputDef, graphOutputDef, graphPropDef, inputDef, pageDef, textDef, uiDefinitions } from './definitions/ui';