📝 (utils.ts): add support for retrieving output IDs from flow data to include in the curl code
📝 (utils.ts): update getCurlCode function to include the arrayOfOutputs in the curl code
This commit is contained in:
parent
17302a825e
commit
01ea9222b8
1 changed files with 25 additions and 2 deletions
|
|
@ -381,16 +381,39 @@ export function getCurlCode(
|
||||||
const tweaks = buildTweaks(flow);
|
const tweaks = buildTweaks(flow);
|
||||||
const inputs = buildInputs();
|
const inputs = buildInputs();
|
||||||
|
|
||||||
|
const arrayOfOutputs = getOutputIds(flow);
|
||||||
|
|
||||||
return `curl -X POST \\
|
return `curl -X POST \\
|
||||||
${window.location.protocol}//${window.location.host}/api/v1/run/${flowId} \\
|
${window.location.protocol}//${window.location.host}/api/v1/run/${flowId} \\
|
||||||
-H 'Content-Type: application/json'\\${
|
-H 'Content-Type: application/json'\\${
|
||||||
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
|
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
|
||||||
}
|
}
|
||||||
-d '{"inputs": [${inputs}], "tweaks": ${
|
-d '{"inputs": [${inputs}],
|
||||||
|
"outputs": [${arrayOfOutputs}],
|
||||||
|
"stream": false,
|
||||||
|
"tweaks": ${
|
||||||
tweak && tweak.length > 0
|
tweak && tweak.length > 0
|
||||||
? buildTweakObject(tweak)
|
? buildTweakObject(tweak)
|
||||||
: JSON.stringify(tweaks, null, 2)
|
: JSON.stringify(tweaks, null, 2)
|
||||||
}}'`;
|
}}'
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getOutputIds(flow) {
|
||||||
|
const nodes = flow.data!.nodes;
|
||||||
|
|
||||||
|
const arrayOfOutputs = nodes.reduce((acc: string[], node) => {
|
||||||
|
if (node.data.type.toLowerCase().includes("output")) {
|
||||||
|
acc.push(node.id);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const arrayOfOutputsJoin = arrayOfOutputs
|
||||||
|
.map((output) => `"${output}"`)
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
|
return arrayOfOutputsJoin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue