$ cat node-template.py
Make Array
// Collects multiple inputs into an ordered array. Add items dynamically and drag to reorder.
Process
Utility
template.py
1import json2import sys345def main():6 try:7 execution_input = json.loads(sys.stdin.read())8 inputs = execution_input.get("inputs", {})9 input_schema = execution_input.get("inputSchema", {})1011 # Sort item_* keys by schema order (user's drag-and-drop order),12 # falling back to numeric suffix for backwards compatibility13 schema_props = input_schema.get("properties", {})1415 def sort_key(k):16 prop = schema_props.get(k, {})17 if "order" in prop:18 return prop["order"]19 # Fallback: numeric suffix20 try:21 return int(k.split("_")[1])22 except (ValueError, IndexError):23 return float("inf")2425 items = []26 item_keys = sorted(27 [k for k in inputs if k.startswith("item_")],28 key=sort_key,29 )3031 for key in item_keys:32 value = inputs.get(key)33 if value is not None and value != "":34 items.append(value)3536 print(f"Collected {len(items)} items from {len(item_keys)} ports", file=sys.stderr)3738 output = {"items": items}39 print(json.dumps(output))4041 except Exception as e:42 import traceback43 error_output = {44 "error": str(e),45 "errorType": type(e).__name__,46 "traceback": traceback.format_exc(),47 }48 print(json.dumps(error_output), file=sys.stderr)49 sys.exit(1)505152if __name__ == "__main__":53 main()