n8n-core 1.46.0 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ export declare const CUSTOM_EXTENSION_ENV = "N8N_CUSTOM_EXTENSIONS";
2
2
  export declare const PLACEHOLDER_EMPTY_EXECUTION_ID = "__UNKNOWN__";
3
3
  export declare const PLACEHOLDER_EMPTY_WORKFLOW_ID = "__EMPTY__";
4
4
  export declare const HTTP_REQUEST_NODE_TYPE = "n8n-nodes-base.httpRequest";
5
+ export declare const HTTP_REQUEST_TOOL_NODE_TYPE = "@n8n/n8n-nodes-langchain.toolHttpRequest";
5
6
  export declare const CUSTOM_NODES_CATEGORY = "Custom Nodes";
6
7
  export declare const RESTRICT_FILE_ACCESS_TO = "N8N_RESTRICT_FILE_ACCESS_TO";
7
8
  export declare const BLOCK_FILE_ACCESS_TO_N8N_FILES = "N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES";
package/dist/Constants.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UM_EMAIL_TEMPLATES_PWRESET = exports.UM_EMAIL_TEMPLATES_INVITE = exports.BINARY_DATA_STORAGE_PATH = exports.CONFIG_FILES = exports.BLOCK_FILE_ACCESS_TO_N8N_FILES = exports.RESTRICT_FILE_ACCESS_TO = exports.CUSTOM_NODES_CATEGORY = exports.HTTP_REQUEST_NODE_TYPE = exports.PLACEHOLDER_EMPTY_WORKFLOW_ID = exports.PLACEHOLDER_EMPTY_EXECUTION_ID = exports.CUSTOM_EXTENSION_ENV = void 0;
3
+ exports.UM_EMAIL_TEMPLATES_PWRESET = exports.UM_EMAIL_TEMPLATES_INVITE = exports.BINARY_DATA_STORAGE_PATH = exports.CONFIG_FILES = exports.BLOCK_FILE_ACCESS_TO_N8N_FILES = exports.RESTRICT_FILE_ACCESS_TO = exports.CUSTOM_NODES_CATEGORY = exports.HTTP_REQUEST_TOOL_NODE_TYPE = exports.HTTP_REQUEST_NODE_TYPE = exports.PLACEHOLDER_EMPTY_WORKFLOW_ID = exports.PLACEHOLDER_EMPTY_EXECUTION_ID = exports.CUSTOM_EXTENSION_ENV = void 0;
4
4
  exports.CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS';
5
5
  exports.PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKNOWN__';
6
6
  exports.PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__';
7
7
  exports.HTTP_REQUEST_NODE_TYPE = 'n8n-nodes-base.httpRequest';
8
+ exports.HTTP_REQUEST_TOOL_NODE_TYPE = '@n8n/n8n-nodes-langchain.toolHttpRequest';
8
9
  exports.CUSTOM_NODES_CATEGORY = 'Custom Nodes';
9
10
  exports.RESTRICT_FILE_ACCESS_TO = 'N8N_RESTRICT_FILE_ACCESS_TO';
10
11
  exports.BLOCK_FILE_ACCESS_TO_N8N_FILES = 'N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES';
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,uBAAuB,CAAC;AAC/C,QAAA,8BAA8B,GAAG,aAAa,CAAC;AAC/C,QAAA,6BAA6B,GAAG,WAAW,CAAC;AAC5C,QAAA,sBAAsB,GAAG,4BAA4B,CAAC;AAEtD,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEvC,QAAA,uBAAuB,GAAG,6BAA6B,CAAC;AACxD,QAAA,8BAA8B,GAAG,oCAAoC,CAAC;AACtE,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAClC,QAAA,wBAAwB,GAAG,8BAA8B,CAAC;AAC1D,QAAA,yBAAyB,GAAG,+BAA+B,CAAC;AAC5D,QAAA,0BAA0B,GAAG,gCAAgC,CAAC"}
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,uBAAuB,CAAC;AAC/C,QAAA,8BAA8B,GAAG,aAAa,CAAC;AAC/C,QAAA,6BAA6B,GAAG,WAAW,CAAC;AAC5C,QAAA,sBAAsB,GAAG,4BAA4B,CAAC;AACtD,QAAA,2BAA2B,GAAG,0CAA0C,CAAC;AAEzE,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEvC,QAAA,uBAAuB,GAAG,6BAA6B,CAAC;AACxD,QAAA,8BAA8B,GAAG,oCAAoC,CAAC;AACtE,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAClC,QAAA,wBAAwB,GAAG,8BAA8B,CAAC;AAC1D,QAAA,yBAAyB,GAAG,+BAA+B,CAAC;AAC5D,QAAA,0BAA0B,GAAG,gCAAgC,CAAC"}
@@ -4,7 +4,7 @@
4
4
  /// <reference types="node/http" />
5
5
  import type { AxiosRequestConfig } from 'axios';
6
6
  import { IncomingMessage } from 'http';
7
- import type { CloseFunction, IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteData, IExecuteFunctions, IExecuteSingleFunctions, IGetNodeParameterOptions, IHookFunctions, IHttpRequestOptions, ILoadOptionsFunctions, INode, INodeExecutionData, INodeType, IOAuth2Options, IPairedItemData, IPollFunctions, IRequestOptions, IRunExecutionData, ITaskDataConnections, ITriggerFunctions, IWebhookData, IWebhookDescription, IWebhookFunctions, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeExecutionWithMetadata, NodeParameterValueType, Workflow, WorkflowActivateMode, WorkflowExecuteMode } from 'n8n-workflow';
7
+ import type { CloseFunction, IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteData, IExecuteFunctions, IExecuteSingleFunctions, IGetNodeParameterOptions, IHookFunctions, IHttpRequestOptions, ILoadOptionsFunctions, INode, INodeExecutionData, INodeType, IOAuth2Options, IPairedItemData, IPollFunctions, IRequestOptions, IRunExecutionData, ITaskDataConnections, ITriggerFunctions, IWebhookData, IWebhookDescription, IWebhookFunctions, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeExecutionWithMetadata, NodeParameterValueType, Workflow, WorkflowActivateMode, WorkflowExecuteMode, EnsureTypeOptions } from 'n8n-workflow';
8
8
  import { Readable } from 'stream';
9
9
  import type { BinaryData } from './BinaryData/types';
10
10
  export declare function parseRequestObject(requestObject: IRequestOptions): Promise<AxiosRequestConfig<any>>;
@@ -33,6 +33,11 @@ export declare function getAdditionalKeys(additionalData: IWorkflowExecuteAdditi
33
33
  export declare function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, executeData?: IExecuteData, runExecutionData?: IRunExecutionData | null, runIndex?: number, connectionInputData?: INodeExecutionData[], itemIndex?: number): Promise<ICredentialDataDecryptedObject>;
34
34
  export declare function cleanupParameterData(inputData: NodeParameterValueType): void;
35
35
  export declare const validateValueAgainstSchema: (node: INode, nodeType: INodeType, parameterValue: string | number | boolean | object | null | undefined, parameterName: string, runIndex: number, itemIndex: number) => any;
36
+ export declare function ensureType(toType: EnsureTypeOptions, parameterValue: any, parameterName: string, errorOptions?: {
37
+ itemIndex?: number;
38
+ runIndex?: number;
39
+ nodeCause?: string;
40
+ }): string | number | boolean | object;
36
41
  export declare function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, connectionInputData: INodeExecutionData[], node: INode, parameterName: string, itemIndex: number, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, executeData?: IExecuteData, fallbackValue?: any, options?: IGetNodeParameterOptions): NodeParameterValueType | object;
37
42
  export declare function continueOnFail(node: INode): boolean;
38
43
  export declare function getNodeWebhookUrl(name: string, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, isTest?: boolean): string | undefined;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getExecuteWebhookFunctions = exports.getExecuteHookFunctions = exports.getLoadOptionsFunctions = exports.getCredentialTestFunctions = exports.getExecuteSingleFunctions = exports.getExecuteFunctions = exports.getExecuteTriggerFunctions = exports.getExecutePollFunctions = exports.copyInputItems = exports.getWebhookDescription = exports.getTimezone = exports.getNodeWebhookUrl = exports.continueOnFail = exports.getNodeParameter = exports.validateValueAgainstSchema = exports.cleanupParameterData = exports.getCredentials = exports.getAdditionalKeys = exports.requestWithAuthentication = exports.normalizeItems = exports.constructExecutionMetaData = exports.returnJsonArray = exports.httpRequestWithAuthentication = exports.requestOAuth1 = exports.requestOAuth2 = exports.copyBinaryFile = exports.setBinaryDataBuffer = exports.getBinaryDataBuffer = exports.assertBinaryData = exports.getBinaryStream = exports.getBinaryMetadata = exports.getBinaryPath = exports.removeEmptyBody = exports.proxyRequestToAxios = exports.parseIncomingMessage = exports.parseRequestObject = void 0;
29
+ exports.getExecuteWebhookFunctions = exports.getExecuteHookFunctions = exports.getLoadOptionsFunctions = exports.getCredentialTestFunctions = exports.getExecuteSingleFunctions = exports.getExecuteFunctions = exports.getExecuteTriggerFunctions = exports.getExecutePollFunctions = exports.copyInputItems = exports.getWebhookDescription = exports.getTimezone = exports.getNodeWebhookUrl = exports.continueOnFail = exports.getNodeParameter = exports.ensureType = exports.validateValueAgainstSchema = exports.cleanupParameterData = exports.getCredentials = exports.getAdditionalKeys = exports.requestWithAuthentication = exports.normalizeItems = exports.constructExecutionMetaData = exports.returnJsonArray = exports.httpRequestWithAuthentication = exports.requestOAuth1 = exports.requestOAuth2 = exports.copyBinaryFile = exports.setBinaryDataBuffer = exports.getBinaryDataBuffer = exports.assertBinaryData = exports.getBinaryStream = exports.getBinaryMetadata = exports.getBinaryPath = exports.removeEmptyBody = exports.proxyRequestToAxios = exports.parseIncomingMessage = exports.parseRequestObject = void 0;
30
30
  const client_oauth2_1 = require("@n8n/client-oauth2");
31
31
  const axios_1 = __importDefault(require("axios"));
32
32
  const crypto_1 = __importStar(require("crypto"));
@@ -1324,7 +1324,7 @@ async function getCredentials(workflow, node, type, additionalData, mode, execut
1324
1324
  if (nodeType === undefined) {
1325
1325
  throw new n8n_workflow_1.NodeOperationError(node, `Node type "${node.type}" is not known so can not get credentials`);
1326
1326
  }
1327
- const fullAccess = [Constants_1.HTTP_REQUEST_NODE_TYPE].includes(node.type);
1327
+ const fullAccess = [Constants_1.HTTP_REQUEST_NODE_TYPE, Constants_1.HTTP_REQUEST_TOOL_NODE_TYPE].includes(node.type);
1328
1328
  let nodeCredentialDescription;
1329
1329
  if (!fullAccess) {
1330
1330
  if (nodeType.description.credentials === undefined) {
@@ -1523,6 +1523,77 @@ const validateValueAgainstSchema = (node, nodeType, parameterValue, parameterNam
1523
1523
  return validationResult.newValue;
1524
1524
  };
1525
1525
  exports.validateValueAgainstSchema = validateValueAgainstSchema;
1526
+ function ensureType(toType, parameterValue, parameterName, errorOptions) {
1527
+ let returnData = parameterValue;
1528
+ if (returnData === null) {
1529
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must not be null`, errorOptions);
1530
+ }
1531
+ if (returnData === undefined) {
1532
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be 'undefined'`, errorOptions);
1533
+ }
1534
+ if (['object', 'array', 'json'].includes(toType)) {
1535
+ if (typeof returnData !== 'object') {
1536
+ if (typeof returnData === 'string' && returnData.length) {
1537
+ try {
1538
+ const parsedValue = JSON.parse(returnData);
1539
+ returnData = parsedValue;
1540
+ }
1541
+ catch (error) {
1542
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be parsed`, {
1543
+ ...errorOptions,
1544
+ description: error.message,
1545
+ });
1546
+ }
1547
+ }
1548
+ else {
1549
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be an ${toType}, but we got '${String(parameterValue)}'`, errorOptions);
1550
+ }
1551
+ }
1552
+ else if (toType === 'json') {
1553
+ try {
1554
+ JSON.stringify(returnData);
1555
+ }
1556
+ catch (error) {
1557
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' is not valid JSON`, {
1558
+ ...errorOptions,
1559
+ description: error.message,
1560
+ });
1561
+ }
1562
+ }
1563
+ if (toType === 'array' && !Array.isArray(returnData)) {
1564
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be an array, but we got object`, errorOptions);
1565
+ }
1566
+ }
1567
+ try {
1568
+ if (toType === 'string') {
1569
+ if (typeof returnData === 'object') {
1570
+ returnData = JSON.stringify(returnData);
1571
+ }
1572
+ else {
1573
+ returnData = String(returnData);
1574
+ }
1575
+ }
1576
+ if (toType === 'number') {
1577
+ returnData = Number(returnData);
1578
+ if (Number.isNaN(returnData)) {
1579
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be a number, but we got '${parameterValue}'`, errorOptions);
1580
+ }
1581
+ }
1582
+ if (toType === 'boolean') {
1583
+ returnData = Boolean(returnData);
1584
+ }
1585
+ }
1586
+ catch (error) {
1587
+ if (error instanceof n8n_workflow_1.ExpressionError)
1588
+ throw error;
1589
+ throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be converted to ${toType}`, {
1590
+ ...errorOptions,
1591
+ description: error.message,
1592
+ });
1593
+ }
1594
+ return returnData;
1595
+ }
1596
+ exports.ensureType = ensureType;
1526
1597
  function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, additionalKeys, executeData, fallbackValue, options) {
1527
1598
  var _a;
1528
1599
  const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
@@ -1557,6 +1628,13 @@ function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputD
1557
1628
  if (options === null || options === void 0 ? void 0 : options.extractValue) {
1558
1629
  returnData = (0, ExtractValue_1.extractValue)(returnData, parameterName, node, nodeType, itemIndex);
1559
1630
  }
1631
+ if (options === null || options === void 0 ? void 0 : options.ensureType) {
1632
+ returnData = ensureType(options.ensureType, returnData, parameterName, {
1633
+ itemIndex,
1634
+ runIndex,
1635
+ nodeCause: node.name,
1636
+ });
1637
+ }
1560
1638
  returnData = (0, exports.validateValueAgainstSchema)(node, nodeType, returnData, parameterName, runIndex, itemIndex);
1561
1639
  return returnData;
1562
1640
  }
@@ -2182,7 +2260,13 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2182
2260
  getMode: () => mode,
2183
2261
  getCredentials: async (type, itemIndex) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
2184
2262
  getExecuteData: () => executeData,
2185
- continueOnFail: () => continueOnFail(node),
2263
+ continueOnFail: (error) => {
2264
+ const shouldContinue = continueOnFail(node);
2265
+ if (error && shouldContinue && !(error instanceof n8n_workflow_1.ApplicationError)) {
2266
+ error.message = n8n_workflow_1.OBFUSCATED_ERROR_MESSAGE;
2267
+ }
2268
+ return shouldContinue;
2269
+ },
2186
2270
  evaluateExpression: (expression, itemIndex) => {
2187
2271
  return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
2188
2272
  },