Skip to content

Commit

Permalink
fix(core): Revert all the context helpers changes (#11616)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Nov 7, 2024
1 parent 2728f7e commit 20fd38f
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 803 deletions.
22 changes: 16 additions & 6 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import type {
AiEvent,
ISupplyDataFunctions,
WebhookType,
SchedulingFunctions,
} from 'n8n-workflow';
import {
NodeConnectionType,
Expand Down Expand Up @@ -172,6 +173,7 @@ import {
TriggerContext,
WebhookContext,
} from './node-execution-context';
import { ScheduledTaskManager } from './ScheduledTaskManager';
import { getSecretsProxy } from './Secrets';
import { SSHClientsManager } from './SSHClientsManager';

Expand Down Expand Up @@ -3023,7 +3025,7 @@ const executionCancellationFunctions = (
},
});

const getRequestHelperFunctions = (
export const getRequestHelperFunctions = (
workflow: Workflow,
node: INode,
additionalData: IWorkflowExecuteAdditionalData,
Expand Down Expand Up @@ -3343,11 +3345,19 @@ const getRequestHelperFunctions = (
};
};

const getSSHTunnelFunctions = (): SSHTunnelFunctions => ({
export const getSSHTunnelFunctions = (): SSHTunnelFunctions => ({
getSSHClient: async (credentials) =>
await Container.get(SSHClientsManager).getClient(credentials),
});

export const getSchedulingFunctions = (workflow: Workflow): SchedulingFunctions => {
const scheduledTaskManager = Container.get(ScheduledTaskManager);
return {
registerCron: (cronExpression, onTick) =>
scheduledTaskManager.registerCron(workflow, cronExpression, onTick),
};
};

const getAllowedPaths = () => {
const restrictFileAccessTo = process.env[RESTRICT_FILE_ACCESS_TO];
if (!restrictFileAccessTo) {
Expand Down Expand Up @@ -3414,7 +3424,7 @@ export function isFilePathBlocked(filePath: string): boolean {
return false;
}

const getFileSystemHelperFunctions = (node: INode): FileSystemHelperFunctions => ({
export const getFileSystemHelperFunctions = (node: INode): FileSystemHelperFunctions => ({
async createReadStream(filePath) {
try {
await fsAccess(filePath);
Expand Down Expand Up @@ -3450,15 +3460,15 @@ const getFileSystemHelperFunctions = (node: INode): FileSystemHelperFunctions =>
},
});

const getNodeHelperFunctions = (
export const getNodeHelperFunctions = (
{ executionId }: IWorkflowExecuteAdditionalData,
workflowId: string,
): NodeHelperFunctions => ({
copyBinaryFile: async (filePath, fileName, mimeType) =>
await copyBinaryFile(workflowId, executionId!, filePath, fileName, mimeType),
});

const getBinaryHelperFunctions = (
export const getBinaryHelperFunctions = (
{ executionId }: IWorkflowExecuteAdditionalData,
workflowId: string,
): BinaryHelperFunctions => ({
Expand All @@ -3476,7 +3486,7 @@ const getBinaryHelperFunctions = (
},
});

const getCheckProcessedHelperFunctions = (
export const getCheckProcessedHelperFunctions = (
workflow: Workflow,
node: INode,
): DeduplicationHelperFunctions => ({
Expand Down
14 changes: 10 additions & 4 deletions packages/core/src/node-execution-context/execute-single-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import {
continueOnFail,
getAdditionalKeys,
getBinaryDataBuffer,
getBinaryHelperFunctions,
getCredentials,
getNodeParameter,
getRequestHelperFunctions,
returnJsonArray,
} from '@/NodeExecuteFunctions';

import { BinaryHelpers } from './helpers/binary-helpers';
import { RequestHelpers } from './helpers/request-helpers';
import { NodeExecutionContext } from './node-execution-context';

export class ExecuteSingleContext extends NodeExecutionContext implements IExecuteSingleFunctions {
Expand All @@ -57,8 +57,14 @@ export class ExecuteSingleContext extends NodeExecutionContext implements IExecu
this.helpers = {
createDeferredPromise,
returnJsonArray,
...new BinaryHelpers(workflow, additionalData).exported,
...new RequestHelpers(this, workflow, node, additionalData).exported,
...getRequestHelperFunctions(
workflow,
node,
additionalData,
runExecutionData,
connectionInputData,
),
...getBinaryHelperFunctions(additionalData, workflow.id),

assertBinaryData: (propertyName, inputIndex = 0) =>
assertBinaryData(inputData, node, itemIndex, propertyName, inputIndex),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 20fd38f

Please sign in to comment.