/**
* Strips metadata from configuration values for scheduled runs.
*
* @param {object} config The configuration object.
* @returns {object} A new configuration object with metadata stripped.
*/
function stripMetadata(config) {
if (!config) {
return {}; // Return empty object if input is null or undefined
}
const strippedConfig = {};
for (const key in config) {
if (config.hasOwnProperty(key)) {
const value = config[key];
if (typeof value === 'string') {
// Remove metadata from strings (e.g., from a JSON string)
strippedConfig[key] = JSON.parse(value);
} else if (typeof value === 'object' && value !== null) {
// Recursively strip metadata from objects
strippedConfig[key] = stripMetadata(value);
} else {
// Keep primitive values as they are
strippedConfig[key] = value;
}
}
}
return strippedConfig;
}
Add your comment