mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat(core): Add Tournament as the new default expression evaluator (#6964)
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as tmpl from '@n8n_io/riot-tmpl';
|
||||
import { DateTime, Duration, Interval } from 'luxon';
|
||||
import * as tmpl from '@n8n_io/riot-tmpl';
|
||||
|
||||
import type {
|
||||
IDataObject,
|
||||
@@ -22,6 +22,7 @@ import type { Workflow } from './Workflow';
|
||||
import { extend, extendOptional } from './Extensions';
|
||||
import { extendedFunctions } from './Extensions/ExtendedFunctions';
|
||||
import { extendSyntax } from './Extensions/ExpressionExtension';
|
||||
import { evaluateExpression, setErrorHandler } from './ExpressionEvaluatorProxy';
|
||||
|
||||
const IS_FRONTEND_IN_DEV_MODE =
|
||||
typeof process === 'object' &&
|
||||
@@ -40,13 +41,10 @@ export const isExpressionError = (error: unknown): error is ExpressionError =>
|
||||
export const isTypeError = (error: unknown): error is TypeError =>
|
||||
error instanceof TypeError || (error instanceof Error && error.name === 'TypeError');
|
||||
|
||||
// Set it to use double curly brackets instead of single ones
|
||||
tmpl.brackets.set('{{ }}');
|
||||
|
||||
// Make sure that error get forwarded
|
||||
tmpl.tmpl.errorHandler = (error: Error) => {
|
||||
setErrorHandler((error: Error) => {
|
||||
if (isExpressionError(error)) throw error;
|
||||
};
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const AsyncFunction = (async () => {}).constructor as FunctionConstructor;
|
||||
@@ -339,7 +337,7 @@ export class Expression {
|
||||
[Function, AsyncFunction].forEach(({ prototype }) =>
|
||||
Object.defineProperty(prototype, 'constructor', { value: fnConstructors.mock }),
|
||||
);
|
||||
return tmpl.tmpl(expression, data);
|
||||
return evaluateExpression(expression, data);
|
||||
} catch (error) {
|
||||
if (isExpressionError(error)) throw error;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user