mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Add batching and other options to declarative nodes (#8885)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -272,6 +272,134 @@ const commonCORSParameters: INodeProperties[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const declarativeNodeOptionParameters: INodeProperties = {
|
||||
displayName: 'Request Options',
|
||||
name: 'requestOptions',
|
||||
type: 'collection',
|
||||
isNodeSetting: true,
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Batching',
|
||||
name: 'batching',
|
||||
placeholder: 'Add Batching',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
default: {
|
||||
batch: {},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Batching',
|
||||
name: 'batch',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Items per Batch',
|
||||
name: 'batchSize',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: -1,
|
||||
},
|
||||
default: 50,
|
||||
description:
|
||||
'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
|
||||
},
|
||||
{
|
||||
displayName: 'Batch Interval (ms)',
|
||||
name: 'batchInterval',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
},
|
||||
default: 1000,
|
||||
description: 'Time (in milliseconds) between each batch of requests. 0 for disabled.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Ignore SSL Issues',
|
||||
name: 'allowUnauthorizedCerts',
|
||||
type: 'boolean',
|
||||
noDataExpression: true,
|
||||
default: false,
|
||||
description:
|
||||
'Whether to accept the response even if SSL certificate validation is not possible',
|
||||
},
|
||||
{
|
||||
displayName: 'Proxy',
|
||||
name: 'proxy',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. http://myproxy:3128',
|
||||
description:
|
||||
'HTTP proxy to use. If authentication is required it can be defined as follow: http://username:password@myproxy:3128',
|
||||
},
|
||||
{
|
||||
displayName: 'Timeout',
|
||||
name: 'timeout',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
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',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export function applyDeclarativeNodeOptionParameters(nodeType: INodeType): void {
|
||||
if (nodeType.execute || nodeType.trigger || nodeType.webhook || nodeType.description.polling) {
|
||||
return;
|
||||
}
|
||||
|
||||
const parameters = nodeType.description.properties;
|
||||
|
||||
if (!parameters) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Was originally under "options" instead of "requestOptions" so the chance
|
||||
// that that existed was quite high. With this name the chance is actually
|
||||
// very low that it already exists but lets leave it in anyway to be sure.
|
||||
const existingRequestOptionsIndex = parameters.findIndex(
|
||||
(parameter) => parameter.name === 'requestOptions',
|
||||
);
|
||||
if (existingRequestOptionsIndex !== -1) {
|
||||
parameters[existingRequestOptionsIndex] = {
|
||||
...declarativeNodeOptionParameters,
|
||||
options: [
|
||||
...(declarativeNodeOptionParameters.options || []),
|
||||
...(parameters[existingRequestOptionsIndex]?.options || []),
|
||||
],
|
||||
};
|
||||
|
||||
if (parameters[existingRequestOptionsIndex]?.options) {
|
||||
parameters[existingRequestOptionsIndex].options!.sort((a, b) => {
|
||||
if ('displayName' in a && 'displayName' in b) {
|
||||
if (a.displayName < b.displayName) {
|
||||
return -1;
|
||||
}
|
||||
if (a.displayName > b.displayName) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
parameters.push(declarativeNodeOptionParameters);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply special parameters which should be added to nodeTypes depending on their type or configuration
|
||||
*/
|
||||
@@ -289,6 +417,8 @@ export function applySpecialNodeParameters(nodeType: INodeType): void {
|
||||
];
|
||||
else properties.push(...commonCORSParameters);
|
||||
}
|
||||
|
||||
applyDeclarativeNodeOptionParameters(nodeType);
|
||||
}
|
||||
|
||||
const getPropertyValues = (
|
||||
|
||||
Reference in New Issue
Block a user