Merge pull request #1800 from mokeyish/patch-2

Allow default variable values ​​when testing CustomFunction
pull/1832/head
Henry Heng 2024-02-27 12:37:06 +08:00 committed by GitHub
commit 2d9bf585f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -324,7 +324,10 @@ export class App {
// execute custom function node
this.app.post('/api/v1/node-custom-function', async (req: Request, res: Response) => {
const body = req.body
const nodeData = { inputs: body }
const functionInputVariables = Object.fromEntries(
[...(body?.javascriptFunction ?? '').matchAll(/\$([a-zA-Z0-9_]+)/g)].map((g) => [g[1], undefined])
)
const nodeData = { inputs: { functionInputVariables, ...body } }
if (Object.prototype.hasOwnProperty.call(this.nodesPool.componentNodes, 'customFunction')) {
try {
const nodeInstanceFilePath = this.nodesPool.componentNodes['customFunction'].filePath as string