MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / deserializeNodeData

Function deserializeNodeData

ts/workflow-core/src/node/serialization.ts:329–565  ·  view source on GitHub ↗

Build the NodeData payload from an API Node (no position).

(apiNode: Schemas["Node"], resolveFunctionInfo?: ResolveFunctionInfo)

Source from the content-addressed store, hash-verified

327 toolDescription: data.arguments.toolDescription,
328 // Unset stays unset — Number(undefined) is NaN, which stringifies to null.
329 qos: draft(data.arguments.qos === undefined ? undefined : (Number(data.arguments.qos) as 0 | 1 | 2)),
330 retain: data.arguments.retain,
331 },
332 };
333 case "OnMqttMessage":
334 return {
335 id: data.id,
336 type: data.type,
337 position: position,
338 arguments: {
339 channelReference: data.arguments.channelReference ?? "",
340 dataType: data.arguments.dataType,
341 output: data.arguments.output,
342 },
343 };
344 }
345}
346
347/**
348 * Convert a strict API Node to a domain Node (NodeData + position). `resolveFunctionInfo`
349 * is required only for `FunctionCall` nodes — see {@link ResolveFunctionInfo}.
350 */
351export function deserialize(apiNode: ApiNode, resolveFunctionInfo?: ResolveFunctionInfo): Node {
352 return { ...deserializeNodeData(apiNode, resolveFunctionInfo), position: apiNode.position };
353}
354
355/** Build the NodeData payload from an API Node (no position). */
356function deserializeNodeData(apiNode: Schemas["Node"], resolveFunctionInfo?: ResolveFunctionInfo): NodeData {
357 switch (apiNode.type) {
358 case "ReadPin":
359 return {
360 id: apiNode.id,
361 type: apiNode.type,
362 label: apiNode.label,
363 arguments: {
364 pinReference: apiNode.arguments.pinReference ?? "",
365 signalType: apiNode.arguments.signalType,
366 output: apiNode.arguments.output as OutputBinding,
367 toolDescription: apiNode.arguments.toolDescription,
368 },
369 };
370 case "SerialRead":
371 return {
372 id: apiNode.id,
373 type: apiNode.type,
374 label: apiNode.label,
375 arguments: {
376 portReference: apiNode.arguments.portReference ?? "",
377 prompt: apiNode.arguments.prompt ?? "",
378 output: apiNode.arguments.output as OutputBinding,
379 },
380 };
381 case "Retriever":
382 return {
383 id: apiNode.id,
384 type: apiNode.type,
385 label: apiNode.label,
386 arguments: {

Callers 1

deserializeFunction · 0.85

Calls 1

resolveFunctionInfoFunction · 0.85

Tested by

no test coverage detected