mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Automatically convert Luxon Dates to string (#3266)
This commit is contained in:
@@ -1386,6 +1386,36 @@ export function getNode(node: INode): INode {
|
|||||||
return JSON.parse(JSON.stringify(node));
|
return JSON.parse(JSON.stringify(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up parameter data to make sure that only valid data gets returned
|
||||||
|
* INFO: Currently only converts Luxon Dates as we know for sure it will not be breaking
|
||||||
|
*/
|
||||||
|
function cleanupParameterData(
|
||||||
|
inputData: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
|
||||||
|
): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] {
|
||||||
|
if (inputData === null || inputData === undefined) {
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(inputData)) {
|
||||||
|
inputData.forEach((value) => cleanupParameterData(value));
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputData.constructor.name === 'DateTime') {
|
||||||
|
// Is a special luxon date so convert to string
|
||||||
|
return inputData.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof inputData === 'object') {
|
||||||
|
Object.keys(inputData).forEach((key) => {
|
||||||
|
inputData[key] = cleanupParameterData(inputData[key]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the requested resolved (all expressions replaced) node parameters.
|
* Returns the requested resolved (all expressions replaced) node parameters.
|
||||||
*
|
*
|
||||||
@@ -1437,6 +1467,8 @@ export function getNodeParameter(
|
|||||||
timezone,
|
timezone,
|
||||||
additionalKeys,
|
additionalKeys,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
returnData = cleanupParameterData(returnData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
e.message += ` [Error in parameter: "${parameterName}"]`;
|
e.message += ` [Error in parameter: "${parameterName}"]`;
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
Reference in New Issue
Block a user