Skip to content

Commit d8af5ef

Browse files
authored
Allow default variable values ​​when testing CustomFunction
```js const question = $question ?? 'my default question' ```
1 parent 39f6991 commit d8af5ef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/server/src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ export class App {
307307
// execute custom function node
308308
this.app.post('/api/v1/node-custom-function', async (req: Request, res: Response) => {
309309
const body = req.body
310-
const nodeData = { inputs: body }
310+
const functionInputVariables = Object.fromEntries(
311+
[...(body?.javascriptFunction ?? '').matchAll(/\$([a-zA-Z0-9_]+)/g)].map((g) => [g[1], undefined])
312+
)
313+
const nodeData = { inputs: { functionInputVariables, ...body } }
311314
if (Object.prototype.hasOwnProperty.call(this.nodesPool.componentNodes, 'customFunction')) {
312315
try {
313316
const nodeInstanceFilePath = this.nodesPool.componentNodes['customFunction'].filePath as string

0 commit comments

Comments
 (0)