import type { NodeDef } from '../../NodeRegistry'; import { asEntity, asString } from '../../values'; import { obj, str } from '../shared'; export const ChildByName: NodeDef = { type: 'ChildByName', label: 'Child by name', category: 'data', description: 'Finds an object by its name below the given one – among its children, their children and so on. ' + 'The nearest level wins; within a level, the first in hierarchy order. Nothing when none is called so.', inputs: [obj('object'), str('name')], outputs: [obj('child')], params: [], run: (ctx, inputs) => { const parent = asEntity(inputs.object); const name = asString(inputs.name); return { outputs: { child: parent ? ctx.childByName(parent, name) : null } }; }, };