n8n-workflow
Advanced tools
Comparing version 0.140.0 to 0.141.0
@@ -11,3 +11,2 @@ import * as tmpl from '@n8n_io/riot-tmpl'; | ||
private renderExpression; | ||
extendSyntax(bracketedExpression: string): string; | ||
getSimpleParameterValue(node: INode, parameterValue: string | boolean | undefined, mode: WorkflowExecuteMode, timezone: string, additionalKeys: IWorkflowDataProxyAdditionalKeys, executeData?: IExecuteData, defaultValue?: boolean | number | string): boolean | number | string | undefined; | ||
@@ -14,0 +13,0 @@ getComplexParameterValue(node: INode, parameterValue: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[], mode: WorkflowExecuteMode, timezone: string, additionalKeys: IWorkflowDataProxyAdditionalKeys, executeData?: IExecuteData, defaultValue?: NodeParameterValueType | undefined, selfData?: {}): NodeParameterValueType | undefined; |
@@ -32,5 +32,4 @@ "use strict"; | ||
const Extensions_1 = require("./Extensions"); | ||
const ExpressionParser_1 = require("./Extensions/ExpressionParser"); | ||
const ExtendedFunctions_1 = require("./Extensions/ExtendedFunctions"); | ||
const ExpressionExtension_1 = require("./Extensions/ExpressionExtension"); | ||
const ExtendedFunctions_1 = require("./Extensions/ExtendedFunctions"); | ||
tmpl.brackets.set('{{ }}'); | ||
@@ -185,3 +184,3 @@ tmpl.tmpl.errorHandler = (error) => { | ||
} | ||
const extendedExpression = this.extendSyntax(parameterValue); | ||
const extendedExpression = (0, ExpressionExtension_1.extendSyntax)(parameterValue); | ||
const returnValue = this.renderExpression(extendedExpression, data); | ||
@@ -236,28 +235,2 @@ if (typeof returnValue === 'function') { | ||
} | ||
extendSyntax(bracketedExpression) { | ||
const chunks = (0, ExpressionParser_1.splitExpression)(bracketedExpression); | ||
const codeChunks = chunks | ||
.filter((c) => c.type === 'code') | ||
.map((c) => c.text.replace(/("|').*?("|')/, '').trim()); | ||
if (!codeChunks.some(Extensions_1.hasExpressionExtension) || (0, Extensions_1.hasNativeMethod)(bracketedExpression)) | ||
return bracketedExpression; | ||
const extendedChunks = chunks.map((chunk) => { | ||
if (chunk.type === 'code') { | ||
const output = (0, ExpressionExtension_1.extendTransform)(chunk.text); | ||
if (!(output === null || output === void 0 ? void 0 : output.code)) { | ||
throw new ExpressionError_1.ExpressionExtensionError('invalid syntax'); | ||
} | ||
let text = output.code; | ||
if (text.trim().endsWith(';')) { | ||
text = text.trim().slice(0, -1); | ||
} | ||
return { | ||
...chunk, | ||
text, | ||
}; | ||
} | ||
return chunk; | ||
}); | ||
return (0, ExpressionParser_1.joinExpression)(extendedChunks); | ||
} | ||
getSimpleParameterValue(node, parameterValue, mode, timezone, additionalKeys, executeData, defaultValue) { | ||
@@ -264,0 +237,0 @@ if (parameterValue === undefined) { |
@@ -9,1 +9,2 @@ export declare const EXTENSION_OBJECTS: import("./Extensions").ExtensionMap[]; | ||
export declare function extendOptional(input: unknown, functionName: string): Function | undefined; | ||
export declare function extendSyntax(bracketedExpression: string, forceExtend?: boolean): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extendOptional = exports.extend = exports.extendTransform = exports.hasNativeMethod = exports.hasExpressionExtension = exports.EXTENSION_OBJECTS = void 0; | ||
exports.extendSyntax = exports.extendOptional = exports.extend = exports.extendTransform = exports.hasNativeMethod = exports.hasExpressionExtension = exports.EXTENSION_OBJECTS = void 0; | ||
const luxon_1 = require("luxon"); | ||
@@ -14,2 +14,3 @@ const ExpressionError_1 = require("../ExpressionError"); | ||
const ObjectExtensions_1 = require("./ObjectExtensions"); | ||
const ExpressionParser_1 = require("./ExpressionParser"); | ||
const EXPRESSION_EXTENDER = 'extend'; | ||
@@ -318,2 +319,40 @@ const EXPRESSION_EXTENDER_OPTIONAL = 'extendOptional'; | ||
exports.extendOptional = extendOptional; | ||
const EXTENDED_SYNTAX_CACHE = {}; | ||
function extendSyntax(bracketedExpression, forceExtend = false) { | ||
const chunks = (0, ExpressionParser_1.splitExpression)(bracketedExpression); | ||
const codeChunks = chunks | ||
.filter((c) => c.type === 'code') | ||
.map((c) => c.text.replace(/("|').*?("|')/, '').trim()); | ||
if ((!codeChunks.some(exports.hasExpressionExtension) || (0, exports.hasNativeMethod)(bracketedExpression)) && | ||
!forceExtend) { | ||
return bracketedExpression; | ||
} | ||
if (bracketedExpression in EXTENDED_SYNTAX_CACHE) { | ||
return EXTENDED_SYNTAX_CACHE[bracketedExpression]; | ||
} | ||
const extendedChunks = chunks.map((chunk) => { | ||
if (chunk.type === 'code') { | ||
let output = (0, exports.extendTransform)(chunk.text); | ||
if (!(output === null || output === void 0 ? void 0 : output.code) && chunk.text.trim()[0] === '{') { | ||
output = (0, exports.extendTransform)(`(${chunk.text})`); | ||
} | ||
if (!(output === null || output === void 0 ? void 0 : output.code)) { | ||
throw new ExpressionError_1.ExpressionExtensionError('invalid syntax'); | ||
} | ||
let text = output.code; | ||
if (text.trim().endsWith(';')) { | ||
text = text.trim().slice(0, -1); | ||
} | ||
return { | ||
...chunk, | ||
text, | ||
}; | ||
} | ||
return chunk; | ||
}); | ||
const expression = (0, ExpressionParser_1.joinExpression)(extendedChunks); | ||
EXTENDED_SYNTAX_CACHE[bracketedExpression] = expression; | ||
return expression; | ||
} | ||
exports.extendSyntax = extendSyntax; | ||
//# sourceMappingURL=ExpressionExtension.js.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import * as LoggerProxy from './LoggerProxy'; | ||
@@ -7,2 +8,3 @@ export * as ErrorReporterProxy from './ErrorReporterProxy'; | ||
export * from './Authentication'; | ||
export * from './Constants'; | ||
export * from './Cron'; | ||
@@ -30,1 +32,6 @@ export * from './DeferredPromise'; | ||
export type { DocMetadata } from './Extensions'; | ||
declare module 'http' { | ||
interface IncomingMessage { | ||
rawBody: Buffer; | ||
} | ||
} |
@@ -40,2 +40,3 @@ "use strict"; | ||
__exportStar(require("./Authentication"), exports); | ||
__exportStar(require("./Constants"), exports); | ||
__exportStar(require("./Cron"), exports); | ||
@@ -42,0 +43,0 @@ __exportStar(require("./DeferredPromise"), exports); |
@@ -297,4 +297,10 @@ "use strict"; | ||
return true; | ||
if (typeof process === 'undefined' || | ||
process.env.N8N_BLOCK_ENV_ACCESS_IN_NODE === 'true') { | ||
if (typeof process === 'undefined') { | ||
throw new ExpressionError_1.ExpressionError('not accessible via UI, please run node', { | ||
runIndex: that.runIndex, | ||
itemIndex: that.itemIndex, | ||
failExecution: true, | ||
}); | ||
} | ||
if (process.env.N8N_BLOCK_ENV_ACCESS_IN_NODE === 'true') { | ||
throw new ExpressionError_1.ExpressionError('access to env vars denied', { | ||
@@ -301,0 +307,0 @@ causeDetailed: 'If you need access please contact the administrator to remove the environment variable ‘N8N_BLOCK_ENV_ACCESS_IN_NODE‘', |
{ | ||
"name": "n8n-workflow", | ||
"version": "0.140.0", | ||
"version": "0.141.0", | ||
"description": "Workflow base code of n8n", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.md", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
630363
127
8534