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
16 changed files with 146 additions and 159 deletions

View File

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

View File

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

View File

@@ -867,6 +867,7 @@ export function getNodeWebhooks(
node,
webhookDescription.path,
mode,
additionalData.timezone,
{},
);
if (nodeWebhookPath === undefined) {
@@ -890,6 +891,7 @@ export function getNodeWebhooks(
node,
webhookDescription.isFullPath,
'internal',
additionalData.timezone,
{},
false,
) as boolean;
@@ -897,6 +899,7 @@ export function getNodeWebhooks(
node,
webhookDescription.restartWebhook,
'internal',
additionalData.timezone,
{},
false,
) as boolean;
@@ -906,6 +909,7 @@ export function getNodeWebhooks(
node,
webhookDescription.httpMethod,
mode,
additionalData.timezone,
{},
'GET',
);
@@ -937,86 +941,6 @@ export function getNodeWebhooks(
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
*

View File

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

View File

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

View File

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

View File

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

View File

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