UNPKG

n8n-nodes-octavehq

Version:

Octave is the AI-powered messaging brain for B2B go-to-market teams, helping articulate product value, synthesize customer interaction data, and deploy consistent, effective messaging across all channels.

46 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseJsonParameter = parseJsonParameter; exports.deepMerge = deepMerge; exports.applyDisplayOptions = applyDisplayOptions; const n8n_workflow_1 = require("n8n-workflow"); function parseJsonParameter(paramName, itemIndex, defaultValue = '{}') { const jsonString = this.getNodeParameter(paramName, itemIndex, defaultValue); try { if (jsonString.trim() === '' && defaultValue === '{}') { return {}; } return JSON.parse(jsonString); } catch (e) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON in parameter '${paramName}': ${e.message}`, { itemIndex }); } } function deepMerge(target, source) { const isObject = (val) => val !== null && typeof val === 'object' && !Array.isArray(val); const merged = { ...target }; for (const key in source) { const targetValue = merged[key]; const sourceValue = source[key]; if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { merged[key] = Array.from(new Set([...targetValue, ...sourceValue])); } else if (isObject(targetValue) && isObject(sourceValue)) { merged[key] = deepMerge(targetValue, sourceValue); } else { merged[key] = sourceValue; } } return merged; } function applyDisplayOptions(commonDisplayOptions, properties) { return properties.map(prop => { var _a; return ({ ...prop, displayOptions: deepMerge((_a = prop.displayOptions) !== null && _a !== void 0 ? _a : {}, commonDisplayOptions), }); }); } //# sourceMappingURL=utils.js.map