Bugfix/execute custom function to worker (#4440)
* pass execute custom function to worker * update execute function
This commit is contained in:
parent
0a4570ecda
commit
4786aafddc
|
|
@ -77,11 +77,12 @@ export class PredictionQueue extends BaseQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.prototype.hasOwnProperty.call(data, 'isExecuteCustomFunction')) {
|
if (Object.prototype.hasOwnProperty.call(data, 'isExecuteCustomFunction')) {
|
||||||
|
const executeCustomFunctionData = data as any
|
||||||
logger.info(`Executing Custom Function...`)
|
logger.info(`Executing Custom Function...`)
|
||||||
return await executeCustomNodeFunction({
|
return await executeCustomNodeFunction({
|
||||||
appDataSource: this.appDataSource,
|
appDataSource: this.appDataSource,
|
||||||
componentNodes: this.componentNodes,
|
componentNodes: this.componentNodes,
|
||||||
data
|
data: executeCustomFunctionData.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,10 @@ export const executeCustomNodeFunction = async ({
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
const body = data
|
const body = data
|
||||||
const functionInputVariables = Object.fromEntries(
|
const jsFunction = typeof body?.javascriptFunction === 'string' ? body.javascriptFunction : ''
|
||||||
[...(body?.javascriptFunction ?? '').matchAll(/\$([a-zA-Z0-9_]+)/g)].map((g) => [g[1], undefined])
|
const matches = jsFunction.matchAll(/\$([a-zA-Z0-9_]+)/g)
|
||||||
)
|
const matchesArray: RegExpMatchArray[] = Array.from(matches)
|
||||||
|
const functionInputVariables = Object.fromEntries(matchesArray.map((g) => [g[1], undefined]))
|
||||||
if (functionInputVariables && Object.keys(functionInputVariables).length) {
|
if (functionInputVariables && Object.keys(functionInputVariables).length) {
|
||||||
for (const key in functionInputVariables) {
|
for (const key in functionInputVariables) {
|
||||||
if (key.includes('vars')) {
|
if (key.includes('vars')) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue