Skip to content

Commit 0f100b7

Browse files
authored
Merge branch 'main' into fix/tavily-api-key-param
2 parents 4381c8b + 9ae635b commit 0f100b7

5 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/components/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ export const getVars = async (
988988
nodeData: INodeData,
989989
options: ICommonObject
990990
) => {
991-
if (!options.workspaceId) {
991+
if (!options.workspaceId || options.skipVariables) {
992992
return []
993993
}
994994
const variables =

packages/server/src/controllers/nodes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ const executeCustomFunction = async (req: Request, res: Response, next: NextFunc
9494
}
9595
const orgId = req.user?.activeOrganizationId
9696
const workspaceId = req.user?.activeWorkspaceId
97-
const apiResponse = await nodesService.executeCustomFunction(req.body, workspaceId, orgId)
97+
const canViewVariables = !!(req.user?.isOrganizationAdmin || req.user?.permissions?.includes('variables:view'))
98+
const apiResponse = await nodesService.executeCustomFunction(req.body, workspaceId, orgId, canViewVariables)
9899
return res.json(apiResponse)
99100
} catch (error) {
100101
next(error)

packages/server/src/queue/PredictionQueue.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export class PredictionQueue extends BaseQueue {
9292
componentNodes: this.componentNodes,
9393
data: executeCustomFunctionData.data,
9494
workspaceId: executeCustomFunctionData.workspaceId,
95-
orgId: executeCustomFunctionData.orgId
95+
orgId: executeCustomFunctionData.orgId,
96+
canViewVariables: executeCustomFunctionData.canViewVariables
9697
})
9798
}
9899

packages/server/src/services/nodes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ const getSingleNodeAsyncOptions = async (nodeName: string, requestBody: any): Pr
126126
}
127127

128128
// execute custom function node
129-
const executeCustomFunction = async (requestBody: any, workspaceId?: string, orgId?: string) => {
129+
const executeCustomFunction = async (requestBody: any, workspaceId?: string, orgId?: string, canViewVariables?: boolean) => {
130130
const appServer = getRunningExpressApp()
131131
const executeData = {
132132
appDataSource: appServer.AppDataSource,
133133
componentNodes: appServer.nodesPool.componentNodes,
134134
data: requestBody,
135135
isExecuteCustomFunction: true,
136+
canViewVariables,
136137
orgId,
137138
workspaceId
138139
}

packages/server/src/utils/executeCustomNodeFunction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ export const executeCustomNodeFunction = async ({
1111
componentNodes,
1212
data,
1313
workspaceId,
14-
orgId
14+
orgId,
15+
canViewVariables
1516
}: {
1617
appDataSource: DataSource
1718
componentNodes: IComponentNodes
1819
data: any
1920
workspaceId?: string
2021
orgId?: string
22+
canViewVariables?: boolean
2123
}) => {
2224
try {
2325
const body = data
@@ -43,7 +45,8 @@ export const executeCustomNodeFunction = async ({
4345
appDataSource,
4446
databaseEntities,
4547
workspaceId,
46-
orgId
48+
orgId,
49+
skipVariables: !canViewVariables
4750
}
4851

4952
const returnData = await newNodeInstance.init(nodeData, '', options)

0 commit comments

Comments
 (0)