mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IBinaryData,
|
||||
IDataObject,
|
||||
@@ -24,7 +22,6 @@ interface OptionDataParamters {
|
||||
[key: string]: OptionData;
|
||||
}
|
||||
|
||||
|
||||
export class HttpRequest implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'HTTP Request',
|
||||
@@ -49,12 +46,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'httpBasicAuth',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['httpBasicAuth'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -63,12 +56,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'httpDigestAuth',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['httpDigestAuth'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -77,12 +66,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'httpHeaderAuth',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['httpHeaderAuth'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -91,12 +76,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'httpQueryAuth',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['httpQueryAuth'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -105,12 +86,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth1Api',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['oAuth1Api'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -119,12 +96,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2Api',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['oAuth2Api'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -137,12 +110,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'basicAuth',
|
||||
],
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
authentication: ['basicAuth'],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -151,12 +120,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'digestAuth',
|
||||
],
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
authentication: ['digestAuth'],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -165,12 +130,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'headerAuth',
|
||||
],
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
authentication: ['headerAuth'],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -179,12 +140,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'queryAuth',
|
||||
],
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
authentication: ['queryAuth'],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -193,12 +150,8 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth1',
|
||||
],
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
authentication: ['oAuth1'],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -207,9 +160,7 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -232,7 +183,8 @@ export class HttpRequest implements INodeType {
|
||||
{
|
||||
name: 'Predefined Credential Type',
|
||||
value: 'predefinedCredentialType',
|
||||
description: 'We\'ve already implemented auth for many services so that you don\'t have to set it up manually',
|
||||
description:
|
||||
"We've already implemented auth for many services so that you don't have to set it up manually",
|
||||
},
|
||||
{
|
||||
name: 'Generic Credential Type',
|
||||
@@ -243,9 +195,7 @@ export class HttpRequest implements INodeType {
|
||||
default: 'none',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -256,19 +206,11 @@ export class HttpRequest implements INodeType {
|
||||
noDataExpression: true,
|
||||
required: true,
|
||||
default: '',
|
||||
credentialTypes: [
|
||||
'extends:oAuth2Api',
|
||||
'extends:oAuth1Api',
|
||||
'has:authenticate',
|
||||
],
|
||||
credentialTypes: ['extends:oAuth2Api', 'extends:oAuth1Api', 'has:authenticate'],
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'predefinedCredentialType',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['predefinedCredentialType'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -278,17 +220,11 @@ export class HttpRequest implements INodeType {
|
||||
type: 'credentialsSelect',
|
||||
required: true,
|
||||
default: '',
|
||||
credentialTypes: [
|
||||
'has:genericAuth',
|
||||
],
|
||||
credentialTypes: ['has:genericAuth'],
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'genericCredentialType',
|
||||
],
|
||||
'@version': [
|
||||
2,
|
||||
],
|
||||
authentication: ['genericCredentialType'],
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -334,9 +270,7 @@ export class HttpRequest implements INodeType {
|
||||
description: 'The way to authenticate',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [
|
||||
1,
|
||||
],
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -396,7 +330,8 @@ export class HttpRequest implements INodeType {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-ignore-ssl-issues
|
||||
description: 'Whether to download the response even if SSL certificate validation is not possible',
|
||||
description:
|
||||
'Whether to download the response even if SSL certificate validation is not possible',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Format',
|
||||
@@ -427,9 +362,7 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseFormat: [
|
||||
'string',
|
||||
],
|
||||
responseFormat: ['string'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the property to which to write the response data',
|
||||
@@ -442,9 +375,7 @@ export class HttpRequest implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseFormat: [
|
||||
'file',
|
||||
],
|
||||
responseFormat: ['file'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the binary property to which to write the data of the read file',
|
||||
@@ -455,7 +386,8 @@ export class HttpRequest implements INodeType {
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the query and/or body parameter should be set via the value-key pair UI or JSON/RAW',
|
||||
description:
|
||||
'Whether the query and/or body parameter should be set via the value-key pair UI or JSON/RAW',
|
||||
},
|
||||
|
||||
{
|
||||
@@ -483,7 +415,8 @@ export class HttpRequest implements INodeType {
|
||||
minValue: -1,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
|
||||
description:
|
||||
'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
|
||||
},
|
||||
{
|
||||
displayName: 'Body Content Type',
|
||||
@@ -491,11 +424,7 @@ export class HttpRequest implements INodeType {
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/requestMethod': [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
'/requestMethod': ['PATCH', 'POST', 'PUT'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -556,11 +485,7 @@ export class HttpRequest implements INodeType {
|
||||
description: 'Specify the mime type for raw/custom body type',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/requestMethod': [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
'/requestMethod': ['PATCH', 'POST', 'PUT'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -580,9 +505,7 @@ export class HttpRequest implements INodeType {
|
||||
description: 'Whether to output each element of an array as own item',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/responseFormat': [
|
||||
'json',
|
||||
],
|
||||
'/responseFormat': ['json'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -594,19 +517,20 @@ export class HttpRequest implements INodeType {
|
||||
minValue: 1,
|
||||
},
|
||||
default: 10000,
|
||||
description: 'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request',
|
||||
description:
|
||||
'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request',
|
||||
},
|
||||
{
|
||||
displayName: 'Use Querystring',
|
||||
name: 'useQueryString',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether you need arrays to be serialized as foo=bar&foo=baz instead of the default foo[0]=bar&foo[1]=baz',
|
||||
description:
|
||||
'Whether you need arrays to be serialized as foo=bar&foo=baz instead of the default foo[0]=bar&foo[1]=baz',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
// Body Parameter
|
||||
{
|
||||
displayName: 'Send Binary Data',
|
||||
@@ -618,14 +542,8 @@ export class HttpRequest implements INodeType {
|
||||
// 'options.bodyContentType': [
|
||||
// 'raw',
|
||||
// ],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
requestMethod: [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
jsonParameters: [true],
|
||||
requestMethod: ['PATCH', 'POST', 'PUT'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -639,22 +557,15 @@ export class HttpRequest implements INodeType {
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
sendBinaryData: [
|
||||
false,
|
||||
],
|
||||
sendBinaryData: [false],
|
||||
},
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
requestMethod: [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
jsonParameters: [true],
|
||||
requestMethod: ['PATCH', 'POST', 'PUT'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the binary property which contains the data for the file to be uploaded. For Form-Data Multipart, they can be provided in the format: <code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2</code>',
|
||||
description:
|
||||
'Name of the binary property which contains the data for the file to be uploaded. For Form-Data Multipart, they can be provided in the format: <code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2</code>',
|
||||
},
|
||||
{
|
||||
displayName: 'Body Parameters',
|
||||
@@ -662,20 +573,11 @@ export class HttpRequest implements INodeType {
|
||||
type: 'json',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
sendBinaryData: [
|
||||
true,
|
||||
],
|
||||
sendBinaryData: [true],
|
||||
},
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
requestMethod: [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
'DELETE',
|
||||
],
|
||||
jsonParameters: [true],
|
||||
requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -691,15 +593,8 @@ export class HttpRequest implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
requestMethod: [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
'DELETE',
|
||||
],
|
||||
jsonParameters: [false],
|
||||
requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'],
|
||||
},
|
||||
},
|
||||
description: 'The body parameter to send',
|
||||
@@ -735,9 +630,7 @@ export class HttpRequest implements INodeType {
|
||||
type: 'json',
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -753,9 +646,7 @@ export class HttpRequest implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
description: 'The headers to send',
|
||||
@@ -791,9 +682,7 @@ export class HttpRequest implements INodeType {
|
||||
type: 'json',
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -809,9 +698,7 @@ export class HttpRequest implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
description: 'The query parameter to send',
|
||||
@@ -845,12 +732,7 @@ export class HttpRequest implements INodeType {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const fullReponseProperties = [
|
||||
'body',
|
||||
'headers',
|
||||
'statusCode',
|
||||
'statusMessage',
|
||||
];
|
||||
const fullReponseProperties = ['body', 'headers', 'statusCode', 'statusMessage'];
|
||||
|
||||
let authentication;
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
@@ -858,7 +740,10 @@ export class HttpRequest implements INodeType {
|
||||
const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
|
||||
|
||||
try {
|
||||
authentication = this.getNodeParameter('authentication', 0) as 'predefinedCredentialType' | 'genericCredentialType' | 'none';
|
||||
authentication = this.getNodeParameter('authentication', 0) as
|
||||
| 'predefinedCredentialType'
|
||||
| 'genericCredentialType'
|
||||
| 'none';
|
||||
} catch (_) {}
|
||||
|
||||
let httpBasicAuth;
|
||||
@@ -926,11 +811,16 @@ export class HttpRequest implements INodeType {
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
const url = this.getNodeParameter('url', itemIndex) as string;
|
||||
|
||||
if (itemIndex > 0 && options.batchSize as number >= 0 && options.batchInterval as number > 0) {
|
||||
if (
|
||||
itemIndex > 0 &&
|
||||
(options.batchSize as number) >= 0 &&
|
||||
(options.batchInterval as number) > 0
|
||||
) {
|
||||
// defaults batch size to 1 of it's set to 0
|
||||
const batchSize: number = options.batchSize as number > 0 ? options.batchSize as number : 1;
|
||||
const batchSize: number =
|
||||
(options.batchSize as number) > 0 ? (options.batchSize as number) : 1;
|
||||
if (itemIndex % batchSize === 0) {
|
||||
await new Promise(resolve => setTimeout(resolve, options.batchInterval as number));
|
||||
await new Promise((resolve) => setTimeout(resolve, options.batchInterval as number));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -941,7 +831,11 @@ export class HttpRequest implements INodeType {
|
||||
method: requestMethod,
|
||||
uri: url,
|
||||
gzip: true,
|
||||
rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean,
|
||||
rejectUnauthorized: !this.getNodeParameter(
|
||||
'allowUnauthorizedCerts',
|
||||
itemIndex,
|
||||
false,
|
||||
) as boolean,
|
||||
};
|
||||
|
||||
if (fullResponse === true) {
|
||||
@@ -980,40 +874,61 @@ export class HttpRequest implements INodeType {
|
||||
for (const parameterName of Object.keys(jsonParameters)) {
|
||||
optionData = jsonParameters[parameterName] as OptionData;
|
||||
const tempValue = this.getNodeParameter(parameterName, itemIndex, '') as string | object;
|
||||
const sendBinaryData = this.getNodeParameter('sendBinaryData', itemIndex, false) as boolean;
|
||||
const sendBinaryData = this.getNodeParameter(
|
||||
'sendBinaryData',
|
||||
itemIndex,
|
||||
false,
|
||||
) as boolean;
|
||||
|
||||
if (optionData.name === 'body' && parametersAreJson === true) {
|
||||
if (sendBinaryData === true) {
|
||||
|
||||
const contentTypesAllowed = [
|
||||
'raw',
|
||||
'multipart-form-data',
|
||||
];
|
||||
const contentTypesAllowed = ['raw', 'multipart-form-data'];
|
||||
|
||||
if (!contentTypesAllowed.includes(options.bodyContentType as string)) {
|
||||
// As n8n-workflow.NodeHelpers.getParamterResolveOrder can not be changed
|
||||
// easily to handle parameters in dot.notation simply error for now.
|
||||
throw new NodeOperationError(this.getNode(), 'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!', { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!',
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
|
||||
const item = items[itemIndex];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex,
|
||||
});
|
||||
}
|
||||
|
||||
if (options.bodyContentType === 'raw') {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
||||
const binaryPropertyName = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
itemIndex,
|
||||
) as string;
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
binaryPropertyName,
|
||||
);
|
||||
requestOptions.body = binaryDataBuffer;
|
||||
} else if (options.bodyContentType === 'multipart-form-data') {
|
||||
requestOptions.body = {};
|
||||
const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
||||
const binaryPropertyNames = binaryPropertyNameFull.split(',').map(key => key.trim());
|
||||
const binaryPropertyNameFull = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
itemIndex,
|
||||
) as string;
|
||||
const binaryPropertyNames = binaryPropertyNameFull
|
||||
.split(',')
|
||||
.map((key) => key.trim());
|
||||
|
||||
for (const propertyData of binaryPropertyNames) {
|
||||
let propertyName = 'file';
|
||||
@@ -1023,15 +938,25 @@ export class HttpRequest implements INodeType {
|
||||
propertyName = propertyDataParts[0];
|
||||
binaryPropertyName = propertyDataParts[1];
|
||||
} else if (binaryPropertyNames.length > 1) {
|
||||
throw new NodeOperationError(this.getNode(), 'If more than one property should be send it is needed to define the in the format:<code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2"</code>', { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'If more than one property should be send it is needed to define the in the format:<code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2"</code>',
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
);
|
||||
}
|
||||
|
||||
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
binaryPropertyName,
|
||||
);
|
||||
|
||||
requestOptions.body[propertyName] = {
|
||||
value: binaryDataBuffer,
|
||||
@@ -1054,14 +979,21 @@ export class HttpRequest implements INodeType {
|
||||
// @ts-ignore
|
||||
requestOptions[optionData.name] = tempValue;
|
||||
|
||||
// @ts-ignore
|
||||
if (typeof requestOptions[optionData.name] !== 'object' && options.bodyContentType !== 'raw') {
|
||||
if (
|
||||
// @ts-ignore
|
||||
typeof requestOptions[optionData.name] !== 'object' &&
|
||||
options.bodyContentType !== 'raw'
|
||||
) {
|
||||
// If it is not an object && bodyContentType is not 'raw' it must be JSON so parse it
|
||||
try {
|
||||
// @ts-ignore
|
||||
requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`, { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`,
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1087,7 +1019,9 @@ export class HttpRequest implements INodeType {
|
||||
return newValue;
|
||||
}
|
||||
};
|
||||
requestOptions[optionName][parameterDataName] = computeNewValue(requestOptions[optionName][parameterDataName]);
|
||||
requestOptions[optionName][parameterDataName] = computeNewValue(
|
||||
requestOptions[optionName][parameterDataName],
|
||||
);
|
||||
} else if (optionName === 'headers') {
|
||||
// @ts-ignore
|
||||
requestOptions[optionName][parameterDataName.toString().toLowerCase()] = newValue;
|
||||
@@ -1165,9 +1099,11 @@ export class HttpRequest implements INodeType {
|
||||
if (responseFormat === 'json') {
|
||||
requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99';
|
||||
} else if (responseFormat === 'string') {
|
||||
requestOptions.headers!['accept'] = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1';
|
||||
requestOptions.headers!['accept'] =
|
||||
'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1';
|
||||
} else {
|
||||
requestOptions.headers!['accept'] = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7';
|
||||
requestOptions.headers!['accept'] =
|
||||
'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,7 +1117,7 @@ export class HttpRequest implements INodeType {
|
||||
};
|
||||
}
|
||||
this.sendMessageToUI(sendRequest);
|
||||
} catch (e) { }
|
||||
} catch (e) {}
|
||||
|
||||
if (
|
||||
authentication === 'genericCredentialType' ||
|
||||
@@ -1189,21 +1125,18 @@ export class HttpRequest implements INodeType {
|
||||
nodeVersion === 1
|
||||
) {
|
||||
if (oAuth1Api) {
|
||||
requestPromises.push(
|
||||
this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions),
|
||||
);
|
||||
requestPromises.push(this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions));
|
||||
} else if (oAuth2Api) {
|
||||
requestPromises.push(
|
||||
this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { tokenType: 'Bearer' }),
|
||||
this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, {
|
||||
tokenType: 'Bearer',
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
// bearerAuth, queryAuth, headerAuth, digestAuth, none
|
||||
requestPromises.push(
|
||||
this.helpers.request(requestOptions),
|
||||
);
|
||||
requestPromises.push(this.helpers.request(requestOptions));
|
||||
}
|
||||
} else if (authentication === 'predefinedCredentialType' && nodeCredentialType) {
|
||||
|
||||
const oAuth2Options: { [credentialType: string]: IOAuth2Options } = {
|
||||
clickUpOAuth2Api: {
|
||||
keepBearer: false,
|
||||
@@ -1250,16 +1183,14 @@ export class HttpRequest implements INodeType {
|
||||
throw new NodeApiError(this.getNode(), response);
|
||||
} else {
|
||||
// Return the actual reason as error
|
||||
returnItems.push(
|
||||
{
|
||||
json: {
|
||||
error: response.reason,
|
||||
},
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
returnItems.push({
|
||||
json: {
|
||||
error: response.reason,
|
||||
},
|
||||
);
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1290,8 +1221,7 @@ export class HttpRequest implements INodeType {
|
||||
Object.assign(newItem.binary, items[itemIndex].binary);
|
||||
}
|
||||
|
||||
|
||||
const fileName = (url).split('/').pop();
|
||||
const fileName = url.split('/').pop();
|
||||
|
||||
if (fullResponse === true) {
|
||||
const returnItem: IDataObject = {};
|
||||
@@ -1304,11 +1234,17 @@ export class HttpRequest implements INodeType {
|
||||
|
||||
newItem.json = returnItem;
|
||||
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(response!.body, fileName);
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(
|
||||
response!.body,
|
||||
fileName,
|
||||
);
|
||||
} else {
|
||||
newItem.json = items[itemIndex].json;
|
||||
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(response!, fileName);
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(
|
||||
response!,
|
||||
fileName,
|
||||
);
|
||||
}
|
||||
|
||||
returnItems.push(newItem);
|
||||
@@ -1353,7 +1289,11 @@ export class HttpRequest implements INodeType {
|
||||
try {
|
||||
returnItem.body = JSON.parse(returnItem.body);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,17 +1308,23 @@ export class HttpRequest implements INodeType {
|
||||
try {
|
||||
response = JSON.parse(response);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.splitIntoItems === true && Array.isArray(response)) {
|
||||
response.forEach(item => returnItems.push({
|
||||
json: item,
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
}));
|
||||
response.forEach((item) =>
|
||||
returnItems.push({
|
||||
json: item,
|
||||
pairedItem: {
|
||||
item: itemIndex,
|
||||
},
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
returnItems.push({
|
||||
json: response,
|
||||
|
||||
Reference in New Issue
Block a user