mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 16:02:23 +00:00
feat: _value, _index => iter.value, iter.index
This commit is contained in:
@@ -472,12 +472,16 @@ async fn push_next_flow_job(
|
||||
}
|
||||
};
|
||||
let mut args = Map::new();
|
||||
args.insert("_iterator".to_string(), last_result.clone());
|
||||
args.insert(
|
||||
"_index".to_string(),
|
||||
let mut iteration_map = Map::new();
|
||||
iteration_map.insert(
|
||||
"index".to_string(),
|
||||
serde_json::Value::Number(serde_json::Number::from(0)),
|
||||
);
|
||||
args.insert("_value".to_string(), itered[0].clone());
|
||||
iteration_map.insert("value".to_string(), itered[0].clone());
|
||||
args.insert(
|
||||
"iteration".to_string(),
|
||||
serde_json::Value::Object(iteration_map),
|
||||
);
|
||||
match itered {
|
||||
serde_json::Value::Array(arr) => (Some(args), Some((0 as u8, arr, vec![]))),
|
||||
a @ _ => Err(Error::BadRequest(format!(
|
||||
@@ -493,14 +497,19 @@ async fn push_next_flow_job(
|
||||
} if index.to_owned() + 1 < itered.len() as u8 => {
|
||||
let mut args = args.clone();
|
||||
let nindex = index.to_owned() + 1;
|
||||
args.insert(
|
||||
"_index".to_string(),
|
||||
let mut iteration_map = Map::new();
|
||||
iteration_map.insert(
|
||||
"index".to_string(),
|
||||
serde_json::Value::Number(serde_json::Number::from(nindex.to_owned())),
|
||||
);
|
||||
args.insert(
|
||||
"_value".to_string(),
|
||||
iteration_map.insert(
|
||||
"value".to_string(),
|
||||
itered[nindex.to_owned() as usize].clone(),
|
||||
);
|
||||
args.insert(
|
||||
"iteration".to_string(),
|
||||
serde_json::Value::Object(iteration_map),
|
||||
);
|
||||
(
|
||||
Some(args),
|
||||
Some((nindex, itered.clone(), forloop_jobs.clone())),
|
||||
|
||||
@@ -233,13 +233,15 @@ export async function runFlowPreview(args: Record<string, any>, flow: Flow) {
|
||||
function computeFlowInputPull(previewResult: any | undefined, flowInputAsObject: any) {
|
||||
const iteratorValues = (previewResult && Array.isArray(previewResult)) ?
|
||||
{
|
||||
_iterator: previewResult,
|
||||
_value: previewResult[0],
|
||||
_index: `The current index of the iteration as a number (here from 0 to ${previewResult.length - 1})`
|
||||
iter: {
|
||||
value: previewResult[0],
|
||||
index: `The current index of the iteration as a number (here from 0 to ${previewResult.length - 1})`
|
||||
}
|
||||
} : {
|
||||
_iterator: 'All the values returned by the previous step',
|
||||
_value: 'The current value of the iteration as an object',
|
||||
_index: 'The current index of the iteration as a number'
|
||||
iter: {
|
||||
value: 'The current value of the iteration as an object',
|
||||
index: 'The current index of the iteration as a number'
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign(flowInputAsObject, previewResult), iteratorValues)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user