fix(core): Set correct timezone in luxon (#3115)

This commit is contained in:
Jan Oberhauser 2022-04-10 11:33:42 +02:00 committed by GitHub
parent 027dfb2f0a
commit 3763f815bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 146 additions and 159 deletions

View file

@ -79,6 +79,7 @@ export class CredentialsHelper extends ICredentialsHelper {
incomingRequestOptions: IHttpRequestOptions | IRequestOptionsSimplified, incomingRequestOptions: IHttpRequestOptions | IRequestOptionsSimplified,
workflow: Workflow, workflow: Workflow,
node: INode, node: INode,
defaultTimezone: string,
): Promise<IHttpRequestOptions> { ): Promise<IHttpRequestOptions> {
const requestOptions = incomingRequestOptions; const requestOptions = incomingRequestOptions;
const credentialType = this.credentialTypes.getByName(typeName); const credentialType = this.credentialTypes.getByName(typeName);
@ -127,6 +128,7 @@ export class CredentialsHelper extends ICredentialsHelper {
{ $credentials: credentials }, { $credentials: credentials },
workflow, workflow,
node, node,
defaultTimezone,
); );
const value = this.resolveValue( const value = this.resolveValue(
@ -135,6 +137,7 @@ export class CredentialsHelper extends ICredentialsHelper {
{ $credentials: credentials }, { $credentials: credentials },
workflow, workflow,
node, node,
defaultTimezone,
); );
requestOptions.headers[key] = value; requestOptions.headers[key] = value;
} else if (authenticate.type === 'queryAuth') { } else if (authenticate.type === 'queryAuth') {
@ -144,6 +147,7 @@ export class CredentialsHelper extends ICredentialsHelper {
{ $credentials: credentials }, { $credentials: credentials },
workflow, workflow,
node, node,
defaultTimezone,
); );
const value = this.resolveValue( const value = this.resolveValue(
@ -152,6 +156,7 @@ export class CredentialsHelper extends ICredentialsHelper {
{ $credentials: credentials }, { $credentials: credentials },
workflow, workflow,
node, node,
defaultTimezone,
); );
if (!requestOptions.qs) { if (!requestOptions.qs) {
requestOptions.qs = {}; requestOptions.qs = {};
@ -172,6 +177,7 @@ export class CredentialsHelper extends ICredentialsHelper {
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
workflow: Workflow, workflow: Workflow,
node: INode, node: INode,
defaultTimezone: string,
): string { ): string {
if (parameterValue.charAt(0) !== '=') { if (parameterValue.charAt(0) !== '=') {
return parameterValue; return parameterValue;
@ -181,6 +187,7 @@ export class CredentialsHelper extends ICredentialsHelper {
node, node,
parameterValue, parameterValue,
'internal', 'internal',
defaultTimezone,
additionalKeys, additionalKeys,
'', '',
); );
@ -293,6 +300,7 @@ export class CredentialsHelper extends ICredentialsHelper {
nodeCredentials: INodeCredentialsDetails, nodeCredentials: INodeCredentialsDetails,
type: string, type: string,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
defaultTimezone: string,
raw?: boolean, raw?: boolean,
expressionResolveValues?: ICredentialsExpressionResolveValues, expressionResolveValues?: ICredentialsExpressionResolveValues,
): Promise<ICredentialDataDecryptedObject> { ): Promise<ICredentialDataDecryptedObject> {
@ -307,6 +315,7 @@ export class CredentialsHelper extends ICredentialsHelper {
decryptedDataOriginal, decryptedDataOriginal,
type, type,
mode, mode,
defaultTimezone,
expressionResolveValues, expressionResolveValues,
); );
} }
@ -323,6 +332,7 @@ export class CredentialsHelper extends ICredentialsHelper {
decryptedDataOriginal: ICredentialDataDecryptedObject, decryptedDataOriginal: ICredentialDataDecryptedObject,
type: string, type: string,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
defaultTimezone: string,
expressionResolveValues?: ICredentialsExpressionResolveValues, expressionResolveValues?: ICredentialsExpressionResolveValues,
): ICredentialDataDecryptedObject { ): ICredentialDataDecryptedObject {
const credentialsProperties = this.getCredentialsProperties(type); const credentialsProperties = this.getCredentialsProperties(type);
@ -342,14 +352,11 @@ export class CredentialsHelper extends ICredentialsHelper {
} }
if (expressionResolveValues) { if (expressionResolveValues) {
const timezone =
(expressionResolveValues.workflow.settings.timezone as string) || defaultTimezone;
try { try {
const workflow = new Workflow({ decryptedData = expressionResolveValues.workflow.expression.getParameterValue(
nodes: Object.values(expressionResolveValues.workflow.nodes),
connections: expressionResolveValues.workflow.connectionsBySourceNode,
active: false,
nodeTypes: expressionResolveValues.workflow.nodeTypes,
});
decryptedData = workflow.expression.getParameterValue(
decryptedData as INodeParameters, decryptedData as INodeParameters,
expressionResolveValues.runExecutionData, expressionResolveValues.runExecutionData,
expressionResolveValues.runIndex, expressionResolveValues.runIndex,
@ -357,6 +364,7 @@ export class CredentialsHelper extends ICredentialsHelper {
expressionResolveValues.node.name, expressionResolveValues.node.name,
expressionResolveValues.connectionInputData, expressionResolveValues.connectionInputData,
mode, mode,
timezone,
{}, {},
false, false,
decryptedData, decryptedData,
@ -387,6 +395,7 @@ export class CredentialsHelper extends ICredentialsHelper {
node, node,
decryptedData as INodeParameters, decryptedData as INodeParameters,
mode, mode,
defaultTimezone,
{}, {},
undefined, undefined,
decryptedData, decryptedData,

View file

@ -1706,11 +1706,13 @@ class App {
} }
const mode: WorkflowExecuteMode = 'internal'; const mode: WorkflowExecuteMode = 'internal';
const timezone = config.getEnv('generic.timezone');
const credentialsHelper = new CredentialsHelper(encryptionKey); const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted( const decryptedDataOriginal = await credentialsHelper.getDecrypted(
credential as INodeCredentialsDetails, credential as INodeCredentialsDetails,
credential.type, credential.type,
mode, mode,
timezone,
true, true,
); );
@ -1718,6 +1720,7 @@ class App {
decryptedDataOriginal, decryptedDataOriginal,
credential.type, credential.type,
mode, mode,
timezone,
); );
const signatureMethod = _.get(oauthCredentials, 'signatureMethod') as string; const signatureMethod = _.get(oauthCredentials, 'signatureMethod') as string;
@ -1844,17 +1847,20 @@ class App {
} }
const mode: WorkflowExecuteMode = 'internal'; const mode: WorkflowExecuteMode = 'internal';
const timezone = config.getEnv('generic.timezone');
const credentialsHelper = new CredentialsHelper(encryptionKey); const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted( const decryptedDataOriginal = await credentialsHelper.getDecrypted(
credential as INodeCredentialsDetails, credential as INodeCredentialsDetails,
credential.type, credential.type,
mode, mode,
timezone,
true, true,
); );
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites( const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(
decryptedDataOriginal, decryptedDataOriginal,
credential.type, credential.type,
mode, mode,
timezone,
); );
const options: OptionsWithUrl = { const options: OptionsWithUrl = {
@ -1959,11 +1965,13 @@ class App {
} }
const mode: WorkflowExecuteMode = 'internal'; const mode: WorkflowExecuteMode = 'internal';
const timezone = config.getEnv('generic.timezone');
const credentialsHelper = new CredentialsHelper(encryptionKey); const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted( const decryptedDataOriginal = await credentialsHelper.getDecrypted(
credential as INodeCredentialsDetails, credential as INodeCredentialsDetails,
credential.type, credential.type,
mode, mode,
timezone,
true, true,
); );
@ -1971,6 +1979,7 @@ class App {
decryptedDataOriginal, decryptedDataOriginal,
credential.type, credential.type,
mode, mode,
timezone,
); );
const token = new csrf(); const token = new csrf();
@ -2099,17 +2108,20 @@ class App {
} }
const mode: WorkflowExecuteMode = 'internal'; const mode: WorkflowExecuteMode = 'internal';
const timezone = config.getEnv('generic.timezone');
const credentialsHelper = new CredentialsHelper(encryptionKey); const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted( const decryptedDataOriginal = await credentialsHelper.getDecrypted(
credential as INodeCredentialsDetails, credential as INodeCredentialsDetails,
credential.type, credential.type,
mode, mode,
timezone,
true, true,
); );
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites( const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(
decryptedDataOriginal, decryptedDataOriginal,
credential.type, credential.type,
mode, mode,
timezone,
); );
const token = new csrf(); const token = new csrf();

View file

@ -132,26 +132,6 @@ export function encodeWebhookResponse(
return response; return response;
} }
/**
* Returns all the webhooks which should be created for the give workflow
*
* @export
* @param {string} workflowId
* @param {Workflow} workflow
* @returns {IWebhookData[]}
*/
export function getWorkflowWebhooksBasic(workflow: Workflow): IWebhookData[] {
// Check all the nodes in the workflow if they have webhooks
const returnData: IWebhookData[] = [];
for (const node of Object.values(workflow.nodes)) {
returnData.push.apply(returnData, NodeHelpers.getNodeWebhooksBasic(workflow, node));
}
return returnData;
}
/** /**
* Executes a webhook * Executes a webhook
* *
@ -194,39 +174,6 @@ export async function executeWebhook(
$executionId: executionId, $executionId: executionId,
}; };
// Get the responseMode
const responseMode = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseMode,
executionMode,
additionalKeys,
'onReceived',
);
const responseCode = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseCode,
executionMode,
additionalKeys,
200,
) as number;
const responseData = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseData,
executionMode,
additionalKeys,
'firstEntryJson',
);
if (!['onReceived', 'lastNode', 'responseNode'].includes(responseMode as string)) {
// If the mode is not known we error. Is probably best like that instead of using
// the default that people know as early as possible (probably already testing phase)
// that something does not resolve properly.
const errorMessage = `The response mode ${responseMode} is not valid!`;
responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.ResponseError(errorMessage, 500, 500);
}
let user: User; let user: User;
if ( if (
(workflowData as WorkflowEntity).shared?.length && (workflowData as WorkflowEntity).shared?.length &&
@ -244,6 +191,42 @@ export async function executeWebhook(
// Prepare everything that is needed to run the workflow // Prepare everything that is needed to run the workflow
const additionalData = await WorkflowExecuteAdditionalData.getBase(user.id); const additionalData = await WorkflowExecuteAdditionalData.getBase(user.id);
// Get the responseMode
const responseMode = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseMode,
executionMode,
additionalData.timezone,
additionalKeys,
'onReceived',
);
const responseCode = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseCode,
executionMode,
additionalData.timezone,
additionalKeys,
200,
) as number;
const responseData = workflow.expression.getSimpleParameterValue(
workflowStartNode,
webhookData.webhookDescription.responseData,
executionMode,
additionalData.timezone,
additionalKeys,
'firstEntryJson',
);
if (!['onReceived', 'lastNode', 'responseNode'].includes(responseMode as string)) {
// If the mode is not known we error. Is probably best like that instead of using
// the default that people know as early as possible (probably already testing phase)
// that something does not resolve properly.
const errorMessage = `The response mode ${responseMode} is not valid!`;
responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.ResponseError(errorMessage, 500, 500);
}
// Add the Response and Request so that this data can be accessed in the node // Add the Response and Request so that this data can be accessed in the node
additionalData.httpRequest = req; additionalData.httpRequest = req;
additionalData.httpResponse = res; additionalData.httpResponse = res;
@ -302,6 +285,7 @@ export async function executeWebhook(
workflowStartNode, workflowStartNode,
webhookData.webhookDescription.responseHeaders, webhookData.webhookDescription.responseHeaders,
executionMode, executionMode,
additionalData.timezone,
additionalKeys, additionalKeys,
undefined, undefined,
) as { ) as {
@ -560,6 +544,7 @@ export async function executeWebhook(
workflowStartNode, workflowStartNode,
webhookData.webhookDescription.responsePropertyName, webhookData.webhookDescription.responsePropertyName,
executionMode, executionMode,
additionalData.timezone,
additionalKeys, additionalKeys,
undefined, undefined,
); );
@ -572,6 +557,7 @@ export async function executeWebhook(
workflowStartNode, workflowStartNode,
webhookData.webhookDescription.responseContentType, webhookData.webhookDescription.responseContentType,
executionMode, executionMode,
additionalData.timezone,
additionalKeys, additionalKeys,
undefined, undefined,
); );
@ -616,6 +602,7 @@ export async function executeWebhook(
workflowStartNode, workflowStartNode,
webhookData.webhookDescription.responseBinaryPropertyName, webhookData.webhookDescription.responseBinaryPropertyName,
executionMode, executionMode,
additionalData.timezone,
additionalKeys, additionalKeys,
'data', 'data',
); );

View file

@ -277,6 +277,8 @@ describe('CredentialsHelper', () => {
nodeTypes, nodeTypes,
}); });
const timezone = 'America/New_York';
for (const testData of tests) { for (const testData of tests) {
test(testData.description, async () => { test(testData.description, async () => {
const credentialTypes: ICredentialTypeData = { const credentialTypes: ICredentialTypeData = {
@ -296,6 +298,7 @@ describe('CredentialsHelper', () => {
JSON.parse(JSON.stringify(incomingRequestOptions)), JSON.parse(JSON.stringify(incomingRequestOptions)),
workflow, workflow,
node, node,
timezone,
); );
expect(result).toEqual(testData.output); expect(result).toEqual(testData.output);

View file

@ -1100,6 +1100,7 @@ export async function httpRequestWithAuthentication(
requestOptions, requestOptions,
workflow, workflow,
node, node,
additionalData.timezone,
); );
return await httpRequest(requestOptions); return await httpRequest(requestOptions);
@ -1222,6 +1223,7 @@ export async function requestWithAuthentication(
requestOptions as IHttpRequestOptions, requestOptions as IHttpRequestOptions,
workflow, workflow,
node, node,
additionalData.timezone,
); );
return await proxyRequestToAxios(requestOptions as IDataObject); return await proxyRequestToAxios(requestOptions as IDataObject);
@ -1372,6 +1374,7 @@ export async function getCredentials(
nodeCredentials, nodeCredentials,
type, type,
mode, mode,
additionalData.timezone,
false, false,
expressionResolveValues, expressionResolveValues,
); );
@ -1413,6 +1416,7 @@ export function getNodeParameter(
parameterName: string, parameterName: string,
itemIndex: number, itemIndex: number,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
fallbackValue?: any, fallbackValue?: any,
): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object { ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object {
@ -1437,6 +1441,7 @@ export function getNodeParameter(
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
); );
} catch (e) { } catch (e) {
@ -1475,6 +1480,7 @@ export function getNodeWebhookUrl(
node: INode, node: INode,
additionalData: IWorkflowExecuteAdditionalData, additionalData: IWorkflowExecuteAdditionalData,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
isTest?: boolean, isTest?: boolean,
): string | undefined { ): string | undefined {
@ -1493,6 +1499,7 @@ export function getNodeWebhookUrl(
node, node,
webhookDescription.path, webhookDescription.path,
mode, mode,
timezone,
additionalKeys, additionalKeys,
); );
if (path === undefined) { if (path === undefined) {
@ -1503,6 +1510,7 @@ export function getNodeWebhookUrl(
node, node,
webhookDescription.isFullPath, webhookDescription.isFullPath,
mode, mode,
timezone,
additionalKeys, additionalKeys,
false, false,
) as boolean; ) as boolean;
@ -1632,6 +1640,7 @@ export function getExecutePollFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -1785,6 +1794,7 @@ export function getExecuteTriggerFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -1916,6 +1926,7 @@ export function getExecuteFunctions(
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
); );
}, },
@ -1991,6 +2002,7 @@ export function getExecuteFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -2020,6 +2032,7 @@ export function getExecuteFunctions(
connectionInputData, connectionInputData,
{}, {},
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
); );
return dataProxy.getDataProxy(); return dataProxy.getDataProxy();
@ -2173,6 +2186,7 @@ export function getExecuteSingleFunctions(
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
); );
}, },
@ -2249,6 +2263,7 @@ export function getExecuteSingleFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -2266,6 +2281,7 @@ export function getExecuteSingleFunctions(
connectionInputData, connectionInputData,
{}, {},
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
); );
return dataProxy.getDataProxy(); return dataProxy.getDataProxy();
@ -2422,6 +2438,7 @@ export function getLoadOptionsFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
'internal' as WorkflowExecuteMode, 'internal' as WorkflowExecuteMode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -2551,6 +2568,7 @@ export function getExecuteHookFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -2562,6 +2580,7 @@ export function getExecuteHookFunctions(
node, node,
additionalData, additionalData,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
isTest, isTest,
); );
@ -2711,6 +2730,7 @@ export function getExecuteWebhookFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
fallbackValue, fallbackValue,
); );
@ -2746,6 +2766,7 @@ export function getExecuteWebhookFunctions(
node, node,
additionalData, additionalData,
mode, mode,
additionalData.timezone,
getAdditionalKeys(additionalData), getAdditionalKeys(additionalData),
); );
}, },

View file

@ -171,7 +171,7 @@ export default mixins(
$resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME, $resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
}; };
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, activeNode!.name, connectionInputData || [], {}, mode, additionalProxyKeys); const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, activeNode!.name, connectionInputData || [], {}, mode, this.$store.getters.timezone, additionalProxyKeys);
const proxy = dataProxy.getDataProxy(); const proxy = dataProxy.getDataProxy();
const autoCompleteItems = [ const autoCompleteItems = [

View file

@ -386,7 +386,7 @@ export default mixins(
$resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME, $resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
}; };
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, nodeName, connectionInputData, {}, 'manual', additionalKeys); const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, nodeName, connectionInputData, {}, 'manual', this.$store.getters.timezone, additionalKeys);
const proxy = dataProxy.getDataProxy(); const proxy = dataProxy.getDataProxy();
// @ts-ignore // @ts-ignore

View file

@ -249,9 +249,9 @@ export const workflowHelpers = mixins(
const workflowName = this.$store.getters.workflowName; const workflowName = this.$store.getters.workflowName;
if (copyData === true) { if (copyData === true) {
return new Workflow({ id: workflowId, name: workflowName, nodes: JSON.parse(JSON.stringify(nodes)), connections: JSON.parse(JSON.stringify(connections)), active: false, nodeTypes}); return new Workflow({ id: workflowId, name: workflowName, nodes: JSON.parse(JSON.stringify(nodes)), connections: JSON.parse(JSON.stringify(connections)), active: false, nodeTypes, settings: this.$store.getters.workflowSettings});
} else { } else {
return new Workflow({ id: workflowId, name: workflowName, nodes, connections, active: false, nodeTypes}); return new Workflow({ id: workflowId, name: workflowName, nodes, connections, active: false, nodeTypes, settings: this.$store.getters.workflowSettings});
} }
}, },
@ -408,7 +408,7 @@ export const workflowHelpers = mixins(
$resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME, $resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
}; };
return workflow.expression.getParameterValue(parameter, runExecutionData, runIndex, itemIndex, activeNode.name, connectionInputData, 'manual', additionalKeys, false) as IDataObject; return workflow.expression.getParameterValue(parameter, runExecutionData, runIndex, itemIndex, activeNode.name, connectionInputData, 'manual', this.$store.getters.timezone, additionalKeys, false) as IDataObject;
}, },
resolveExpression(expression: string, siblingParameters: INodeParameters = {}) { resolveExpression(expression: string, siblingParameters: INodeParameters = {}) {

View file

@ -69,6 +69,7 @@ export class Expression {
activeNodeName: string, activeNodeName: string,
connectionInputData: INodeExecutionData[], connectionInputData: INodeExecutionData[],
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
returnObjectAsString = false, returnObjectAsString = false,
selfData = {}, selfData = {},
@ -95,6 +96,7 @@ export class Expression {
connectionInputData, connectionInputData,
siblingParameters, siblingParameters,
mode, mode,
timezone,
additionalKeys, additionalKeys,
-1, -1,
selfData, selfData,
@ -157,6 +159,7 @@ export class Expression {
node: INode, node: INode,
parameterValue: string | boolean | undefined, parameterValue: string | boolean | undefined,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
defaultValue?: boolean | number | string, defaultValue?: boolean | number | string,
): boolean | number | string | undefined { ): boolean | number | string | undefined {
@ -183,6 +186,7 @@ export class Expression {
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
) as boolean | number | string | undefined; ) as boolean | number | string | undefined;
} }
@ -200,6 +204,7 @@ export class Expression {
node: INode, node: INode,
parameterValue: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[], parameterValue: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
defaultValue: defaultValue:
| NodeParameterValue | NodeParameterValue
@ -233,6 +238,7 @@ export class Expression {
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
false, false,
selfData, selfData,
@ -247,6 +253,7 @@ export class Expression {
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
false, false,
selfData, selfData,
@ -276,6 +283,7 @@ export class Expression {
activeNodeName: string, activeNodeName: string,
connectionInputData: INodeExecutionData[], connectionInputData: INodeExecutionData[],
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
returnObjectAsString = false, returnObjectAsString = false,
selfData = {}, selfData = {},
@ -301,6 +309,7 @@ export class Expression {
activeNodeName, activeNodeName,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
returnObjectAsString, returnObjectAsString,
selfData, selfData,
@ -315,6 +324,7 @@ export class Expression {
activeNodeName, activeNodeName,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
returnObjectAsString, returnObjectAsString,
selfData, selfData,
@ -332,6 +342,7 @@ export class Expression {
activeNodeName, activeNodeName,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
returnObjectAsString, returnObjectAsString,
selfData, selfData,

View file

@ -160,6 +160,7 @@ export abstract class ICredentialsHelper {
requestOptions: IHttpRequestOptions | IRequestOptionsSimplified, requestOptions: IHttpRequestOptions | IRequestOptionsSimplified,
workflow: Workflow, workflow: Workflow,
node: INode, node: INode,
defaultTimezone: string,
): Promise<IHttpRequestOptions>; ): Promise<IHttpRequestOptions>;
abstract getCredentials( abstract getCredentials(
@ -171,6 +172,7 @@ export abstract class ICredentialsHelper {
nodeCredentials: INodeCredentialsDetails, nodeCredentials: INodeCredentialsDetails,
type: string, type: string,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
defaultTimezone: string,
raw?: boolean, raw?: boolean,
expressionResolveValues?: ICredentialsExpressionResolveValues, expressionResolveValues?: ICredentialsExpressionResolveValues,
): Promise<ICredentialDataDecryptedObject>; ): Promise<ICredentialDataDecryptedObject>;

View file

@ -867,6 +867,7 @@ export function getNodeWebhooks(
node, node,
webhookDescription.path, webhookDescription.path,
mode, mode,
additionalData.timezone,
{}, {},
); );
if (nodeWebhookPath === undefined) { if (nodeWebhookPath === undefined) {
@ -890,6 +891,7 @@ export function getNodeWebhooks(
node, node,
webhookDescription.isFullPath, webhookDescription.isFullPath,
'internal', 'internal',
additionalData.timezone,
{}, {},
false, false,
) as boolean; ) as boolean;
@ -897,6 +899,7 @@ export function getNodeWebhooks(
node, node,
webhookDescription.restartWebhook, webhookDescription.restartWebhook,
'internal', 'internal',
additionalData.timezone,
{}, {},
false, false,
) as boolean; ) as boolean;
@ -906,6 +909,7 @@ export function getNodeWebhooks(
node, node,
webhookDescription.httpMethod, webhookDescription.httpMethod,
mode, mode,
additionalData.timezone,
{}, {},
'GET', 'GET',
); );
@ -937,86 +941,6 @@ export function getNodeWebhooks(
return returnData; return returnData;
} }
export function getNodeWebhooksBasic(workflow: Workflow, node: INode): IWebhookData[] {
if (node.disabled === true) {
// Node is disabled so webhooks will also not be enabled
return [];
}
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion) as INodeType;
if (nodeType.description.webhooks === undefined) {
// Node does not have any webhooks so return
return [];
}
const workflowId = workflow.id || '__UNSAVED__';
const mode = 'internal';
const returnData: IWebhookData[] = [];
for (const webhookDescription of nodeType.description.webhooks) {
let nodeWebhookPath = workflow.expression.getSimpleParameterValue(
node,
webhookDescription.path,
mode,
{},
);
if (nodeWebhookPath === undefined) {
// TODO: Use a proper logger
console.error(
`No webhook path could be found for node "${node.name}" in workflow "${workflowId}".`,
);
continue;
}
nodeWebhookPath = nodeWebhookPath.toString();
if (nodeWebhookPath.startsWith('/')) {
nodeWebhookPath = nodeWebhookPath.slice(1);
}
if (nodeWebhookPath.endsWith('/')) {
nodeWebhookPath = nodeWebhookPath.slice(0, -1);
}
const isFullPath: boolean = workflow.expression.getSimpleParameterValue(
node,
webhookDescription.isFullPath,
mode,
{},
false,
) as boolean;
const path = getNodeWebhookPath(workflowId, node, nodeWebhookPath, isFullPath);
const httpMethod = workflow.expression.getSimpleParameterValue(
node,
webhookDescription.httpMethod,
mode,
{},
);
if (httpMethod === undefined) {
// TODO: Use a proper logger
console.error(
`The webhook "${path}" for node "${node.name}" in workflow "${workflowId}" could not be added because the httpMethod is not defined.`,
);
continue;
}
// @ts-ignore
returnData.push({
httpMethod: httpMethod.toString() as WebhookHttpMethod,
node: node.name,
path,
webhookDescription,
workflowId,
});
}
return returnData;
}
/** /**
* Returns the webhook path * Returns the webhook path
* *

View file

@ -558,6 +558,7 @@ export class RoutingNode {
this.node.name, this.node.name,
this.connectionInputData, this.connectionInputData,
this.mode, this.mode,
this.additionalData.timezone,
additionalKeys ?? {}, additionalKeys ?? {},
returnObjectAsString, returnObjectAsString,
); );

View file

@ -7,7 +7,7 @@
/* eslint-disable no-prototype-builtins */ /* eslint-disable no-prototype-builtins */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
import { DateTime, Duration, Interval } from 'luxon'; import { DateTime, Duration, Interval, Settings } from 'luxon';
import * as jmespath from 'jmespath'; import * as jmespath from 'jmespath';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
@ -47,6 +47,10 @@ export class WorkflowDataProxy {
private additionalKeys: IWorkflowDataProxyAdditionalKeys; private additionalKeys: IWorkflowDataProxyAdditionalKeys;
private defaultTimezone: string;
private timezone: string;
constructor( constructor(
workflow: Workflow, workflow: Workflow,
runExecutionData: IRunExecutionData | null, runExecutionData: IRunExecutionData | null,
@ -56,6 +60,7 @@ export class WorkflowDataProxy {
connectionInputData: INodeExecutionData[], connectionInputData: INodeExecutionData[],
siblingParameters: INodeParameters, siblingParameters: INodeParameters,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
defaultTimezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
defaultReturnRunIndex = -1, defaultReturnRunIndex = -1,
selfData = {}, selfData = {},
@ -69,8 +74,12 @@ export class WorkflowDataProxy {
this.connectionInputData = connectionInputData; this.connectionInputData = connectionInputData;
this.siblingParameters = siblingParameters; this.siblingParameters = siblingParameters;
this.mode = mode; this.mode = mode;
this.defaultTimezone = defaultTimezone;
this.timezone = (this.workflow.settings.timezone as string) || this.defaultTimezone;
this.selfData = selfData; this.selfData = selfData;
this.additionalKeys = additionalKeys; this.additionalKeys = additionalKeys;
Settings.defaultZone = this.timezone;
} }
/** /**
@ -191,6 +200,7 @@ export class WorkflowDataProxy {
that.activeNodeName, that.activeNodeName,
that.connectionInputData, that.connectionInputData,
that.mode, that.mode,
that.timezone,
that.additionalKeys, that.additionalKeys,
); );
} }
@ -633,6 +643,7 @@ export class WorkflowDataProxy {
that.activeNodeName, that.activeNodeName,
that.connectionInputData, that.connectionInputData,
that.mode, that.mode,
that.timezone,
that.additionalKeys, that.additionalKeys,
); );
}, },
@ -647,6 +658,7 @@ export class WorkflowDataProxy {
this.connectionInputData, this.connectionInputData,
that.siblingParameters, that.siblingParameters,
that.mode, that.mode,
that.defaultTimezone,
that.additionalKeys, that.additionalKeys,
defaultReturnRunIndex, defaultReturnRunIndex,
); );

View file

@ -144,6 +144,7 @@ export function getNodeParameter(
parameterName: string, parameterName: string,
itemIndex: number, itemIndex: number,
mode: WorkflowExecuteMode, mode: WorkflowExecuteMode,
timezone: string,
additionalKeys: IWorkflowDataProxyAdditionalKeys, additionalKeys: IWorkflowDataProxyAdditionalKeys,
fallbackValue?: any, fallbackValue?: any,
): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object { ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object {
@ -168,6 +169,7 @@ export function getNodeParameter(
node.name, node.name,
connectionInputData, connectionInputData,
mode, mode,
timezone,
additionalKeys, additionalKeys,
); );
} catch (e) { } catch (e) {
@ -253,6 +255,7 @@ export function getExecuteFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
{}, {},
fallbackValue, fallbackValue,
); );
@ -286,6 +289,7 @@ export function getExecuteFunctions(
connectionInputData, connectionInputData,
{}, {},
mode, mode,
additionalData.timezone,
{}, {},
); );
return dataProxy.getDataProxy(); return dataProxy.getDataProxy();
@ -445,6 +449,7 @@ export function getExecuteSingleFunctions(
parameterName, parameterName,
itemIndex, itemIndex,
mode, mode,
additionalData.timezone,
{}, {},
fallbackValue, fallbackValue,
); );
@ -466,6 +471,7 @@ export function getExecuteSingleFunctions(
connectionInputData, connectionInputData,
{}, {},
mode, mode,
additionalData.timezone,
{}, {},
); );
return dataProxy.getDataProxy(); return dataProxy.getDataProxy();

View file

@ -998,6 +998,7 @@ describe('Workflow', () => {
]; ];
const nodeTypes = Helpers.NodeTypes(); const nodeTypes = Helpers.NodeTypes();
const timezone = 'America/New_York';
for (const testData of tests) { for (const testData of tests) {
test(testData.description, () => { test(testData.description, () => {
@ -1110,6 +1111,7 @@ describe('Workflow', () => {
activeNodeName, activeNodeName,
connectionInputData, connectionInputData,
'manual', 'manual',
timezone,
{}, {},
); );
// @ts-ignore // @ts-ignore
@ -1264,6 +1266,7 @@ describe('Workflow', () => {
activeNodeName, activeNodeName,
connectionInputData, connectionInputData,
'manual', 'manual',
timezone,
{}, {},
); );

View file

@ -1,11 +1,6 @@
import { Workflow, WorkflowDataProxy } from '../src'; import { Workflow, WorkflowDataProxy } from '../src';
import * as Helpers from './Helpers'; import * as Helpers from './Helpers';
import { import { IConnections, INode, INodeExecutionData, IRunExecutionData } from '../src/Interfaces';
IConnections,
INode,
INodeExecutionData,
IRunExecutionData,
} from '../src/Interfaces';
describe('WorkflowDataProxy', () => { describe('WorkflowDataProxy', () => {
describe('test data proxy', () => { describe('test data proxy', () => {
@ -138,8 +133,8 @@ describe('WorkflowDataProxy', () => {
{ json: { length: 160 } }, { json: { length: 160 } },
{ json: { length: 121 } }, { json: { length: 121 } },
{ json: { length: 275 } }, { json: { length: 275 } },
{ json: { length: 950 } } { json: { length: 950 } },
] ];
const nodeTypes = Helpers.NodeTypes(); const nodeTypes = Helpers.NodeTypes();
const workflow = new Workflow({ nodes, connections, active: false, nodeTypes }); const workflow = new Workflow({ nodes, connections, active: false, nodeTypes });
@ -153,6 +148,7 @@ describe('WorkflowDataProxy', () => {
renameNodeConnectionInputData || [], renameNodeConnectionInputData || [],
{}, {},
'manual', 'manual',
'America/New_York',
{}, {},
); );
const proxy = dataProxy.getDataProxy(); const proxy = dataProxy.getDataProxy();