recoco-core 0.2.1

Recoco-core is the core library of Recoco; it's nearly identical to the main ReCoco crate, which is a simple wrapper around recoco-core and other sub-crates.
Documentation
// ReCoco is a Rust-only fork of CocoIndex, by [CocoIndex](https://CocoIndex)
// Original code from CocoIndex is copyrighted by CocoIndex
// SPDX-FileCopyrightText: 2025-2026 CocoIndex (upstream)
// SPDX-FileContributor: CocoIndex Contributors
//
// All modifications from the upstream for ReCoco are copyrighted by Knitli Inc.
// SPDX-FileCopyrightText: 2026 Knitli Inc. (ReCoco)
// SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
//
// Both the upstream CocoIndex code and the ReCoco modifications are licensed under the Apache-2.0 License.
// SPDX-License-Identifier: Apache-2.0
#![allow(dead_code)]
use crate::builder::plan::{
    AnalyzedFieldReference, AnalyzedLocalFieldReference, AnalyzedValueMapping,
};
use crate::ops::sdk::{
    AuthRegistry, BasicValueType, EnrichedValueType, FlowInstanceContext, OpArgSchema,
    SimpleFunctionFactory, Value, make_output_type,
};
use crate::prelude::*;
use std::sync::Arc;

// This function builds an argument schema for a flow function.
#[cfg(feature = "persistence")]
pub fn build_arg_schema(
    name: &str,
    value_type: BasicValueType,
) -> (Option<&str>, EnrichedValueType) {
    (Some(name), make_output_type(value_type))
}

// This function tests a flow function by providing a spec, input argument schemas, and values.
#[cfg(feature = "persistence")]
pub async fn test_flow_function(
    factory: &Arc<impl SimpleFunctionFactory>,
    spec: &impl Serialize,
    input_arg_schemas: &[(Option<&str>, EnrichedValueType)],
    input_arg_values: Vec<Value>,
) -> Result<Value> {
    // 1. Construct OpArgSchema
    let op_arg_schemas: Vec<OpArgSchema> = input_arg_schemas
        .iter()
        .enumerate()
        .map(|(idx, (name, value_type))| OpArgSchema {
            name: name.map_or(crate::base::spec::OpArgName(None), |n| {
                crate::base::spec::OpArgName(Some(n.to_string()))
            }),
            value_type: value_type.clone(),
            analyzed_value: AnalyzedValueMapping::Field(AnalyzedFieldReference {
                local: AnalyzedLocalFieldReference {
                    fields_idx: vec![idx as u32],
                },
                scope_up_level: 0,
            }),
        })
        .collect();

    // 2. Build Executor
    let context = Arc::new(FlowInstanceContext {
        flow_instance_name: "test_flow_function".to_string(),
        auth_registry: Arc::new(AuthRegistry::default()),
    });
    let build_output = factory
        .clone()
        .build(serde_json::to_value(spec)?, op_arg_schemas, context)
        .await?;
    let executor = build_output.executor.await?;

    // 3. Evaluate
    let result = executor.evaluate(input_arg_values).await?;

    Ok(result)
}