mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(HTTP Request Node): Port optimizeResponse from httpRequest tool to standalone node (no-changelog) (#14307)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { optimizeResponseProperties } from '../shared/optimizeResponse';
|
||||
|
||||
export const mainProperties: INodeProperties[] = [
|
||||
{
|
||||
displayName: '',
|
||||
@@ -1167,6 +1169,13 @@ export const mainProperties: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
...optimizeResponseProperties.map((prop) => ({
|
||||
...prop,
|
||||
displayOptions: {
|
||||
...prop.displayOptions,
|
||||
show: { ...prop.displayOptions?.show, '@tool': [true] },
|
||||
},
|
||||
})),
|
||||
{
|
||||
displayName:
|
||||
"You can view the raw requests this node makes in your browser's developer console",
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
sanitizeUiMessage,
|
||||
setAgentOptions,
|
||||
} from '../GenericFunctions';
|
||||
import { configureResponseOptimizer } from '../shared/optimizeResponse';
|
||||
|
||||
function toText<T>(data: T) {
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
@@ -832,6 +833,8 @@ export class HttpRequestV3 implements INodeType {
|
||||
}
|
||||
}
|
||||
}
|
||||
// This is a no-op outside of tool usage
|
||||
const optimizeResponse = configureResponseOptimizer(this, itemIndex);
|
||||
|
||||
if (autoDetectResponseFormat && !fullResponse) {
|
||||
delete response.headers;
|
||||
@@ -839,9 +842,10 @@ export class HttpRequestV3 implements INodeType {
|
||||
delete response.statusMessage;
|
||||
}
|
||||
if (!fullResponse) {
|
||||
response = response.body;
|
||||
response = optimizeResponse(response.body);
|
||||
} else {
|
||||
response.body = optimizeResponse(response.body);
|
||||
}
|
||||
|
||||
if (responseFormat === 'file') {
|
||||
const outputPropertyName = this.getNodeParameter(
|
||||
'options.response.response.outputPropertyName',
|
||||
@@ -911,7 +915,6 @@ export class HttpRequestV3 implements INodeType {
|
||||
returnItem[outputPropertyName] = toText(response[property]);
|
||||
continue;
|
||||
}
|
||||
|
||||
returnItem[property] = response[property];
|
||||
}
|
||||
returnItems.push({
|
||||
@@ -1001,11 +1004,17 @@ export class HttpRequestV3 implements INodeType {
|
||||
returnItems[0].json.data &&
|
||||
Array.isArray(returnItems[0].json.data)
|
||||
) {
|
||||
this.addExecutionHints({
|
||||
message:
|
||||
'To split the contents of ‘data’ into separate items for easier processing, add a ‘Split Out’ node after this one',
|
||||
location: 'outputPane',
|
||||
});
|
||||
const message =
|
||||
'To split the contents of ‘data’ into separate items for easier processing, add a ‘Split Out’ node after this one';
|
||||
|
||||
if (this.addExecutionHints) {
|
||||
this.addExecutionHints({
|
||||
message,
|
||||
location: 'outputPane',
|
||||
});
|
||||
} else {
|
||||
this.logger.info(message);
|
||||
}
|
||||
}
|
||||
|
||||
return [returnItems];
|
||||
|
||||
Reference in New Issue
Block a user