// AUTO-GENERATED — do not edit by hand
// Upstream: https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Function/Function.node.ts
// To implement: copy to ../impl/function.rs, fill in execute(), add to ../impl/mod.rs
// r8r: rust port of n8n.io
// License: Unlicense

use async_trait::async_trait;
use crate::core::error::NodeError;
use crate::core::types::*;
use crate::engine::{ExecuteCtx, Node, NodeFactory};
use std::sync::Arc;

pub struct FunctionNode;

static META: NodeMetadata = NodeMetadata {
    name: "function",
    display_name: "Function",
    version: &[1],
    group: &["transform"],
    description: "Run custom function code which gets executed once and allows you to add, remove, change and replace items",
    inputs: 1,
    outputs: 1,
    properties: &[
    PropertyDef { name: "notice", display_name: "A newer version of this node type is available, called the ‘Code’ node", kind: PropertyKind::Notice, required: false, default: Some("") },
    PropertyDef { name: "functionCode", display_name: "JavaScript Code", kind: PropertyKind::String, required: false, default: Some("// Code here will run only once, no matter how many input items there are.\n// More info and help:https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.function/\n// Tip: You can use luxon for dates and $jmespath for querying JSON structures\n\n// Loop over inputs and add a new field called ") }
],
    credentials: &[],
};

#[async_trait]
impl Node for FunctionNode {
    fn metadata(&self) -> &'static NodeMetadata { &META }

    async fn execute(&self, _ctx: &mut ExecuteCtx<'_>) -> Result<NodeOutput, NodeError> {
    Err(NodeError::NotYetPorted { node: "function", upstream: "https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Function/Function.node.ts" })
    }
}

inventory::submit! { NodeFactory::new("function", || Arc::new(FunctionNode)) }
