MCPcopy Index your code
hub / github.com/pascalorg/editor / parseCreatedNode

Function parseCreatedNode

packages/core/src/store/actions/node-actions.ts:464–479  ·  view source on GitHub ↗
(node: AnyNode, parentId: AnyNodeId | null)

Source from the content-addressed store, hash-verified

462}
463
464function parseCreatedNode(node: AnyNode, parentId: AnyNodeId | null): AnyNode {
465 const candidate = { ...node, parentId }
466 const parsed = AnyNodeSchema.safeParse(candidate)
467 if (parsed.success) return parsed.data
468
469 const schema = getNodeSchemaForType(candidate.type)
470 const sanitized = sanitizeNumericValue(schema, candidate, undefined, [])
471
472 if (sanitized.issues.length === 0) {
473 return candidate as AnyNode
474 }
475
476 warnSanitizedNodeMutation('create', node.id, sanitized.issues)
477
478 return sanitized.value as AnyNode
479}
480
481function parseUpdatedNode(currentNode: AnyNode, data: Partial<AnyNode>): AnyNode {
482 const candidate = { ...currentNode, ...data }

Callers 2

createNodesActionFunction · 0.85
applyNodeChangesActionFunction · 0.85

Calls 3

getNodeSchemaForTypeFunction · 0.85
sanitizeNumericValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…