import { GET_PROPERTIES } from '../../nested'; import type { NodeDef } from '../../NodeRegistry'; import { propertyPort } from '../../propertyPorts'; import { asEntity, type Value } from '../../values'; import { obj } from '../shared'; /** The plural of Get property: one output per property picked, the way Get variables reads. */ export const GetProperties: NodeDef = { type: GET_PROPERTIES, label: 'Get properties', category: 'data', description: 'Reads several properties (width, color, …) of an object at once, one output per property.', inputs: [obj('object')], outputs: [], params: [], declaresPorts: 'outputs', declaredPort: propertyPort, run: (_ctx, inputs, _params, def) => { const target = asEntity(inputs.object); const outputs: Record = {}; for (const port of def.outputs) outputs[port.key] = target?.props[port.key] ?? null; return { outputs }; }, };