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.

142 lines 5.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exportedProperties = void 0; exports.execute = execute; const n8n_workflow_1 = require("n8n-workflow"); const OctaveApiRequest_1 = require("../../transport/OctaveApiRequest"); const utils_1 = require("../utils"); const properties = [ { displayName: 'Product OId', name: 'oId', type: 'string', required: true, default: '', description: 'OId of the product to update', }, { displayName: 'Name', name: 'name', type: 'string', default: '', description: 'Name of the product (optional)', }, { displayName: 'Type', name: 'type', type: 'options', options: [ { name: 'Product', value: 'PRODUCT' }, { name: 'Service', value: 'SERVICE' }, ], default: 'PRODUCT', description: 'Type of the product (optional)', }, { displayName: 'Description', name: 'description', type: 'string', default: '', description: 'Description of the product (optional)', }, { displayName: 'Summary', name: 'summary', type: 'string', default: '', description: 'Summary of the product (optional)', }, { displayName: 'Internal Name', name: 'internalName', type: 'string', default: '', description: 'Internal name of the product (optional)', }, { displayName: 'Primary URL', name: 'primaryUrl', type: 'string', default: '', description: 'Primary URL for the product (optional)', }, { displayName: 'Capabilities (JSON Array)', name: 'capabilities', type: 'json', default: '[]', description: 'JSON array of product capabilities (optional)', typeOptions: { rows: 3 }, }, { displayName: 'Challenges Addressed (JSON Array)', name: 'challengesAddressed', type: 'json', default: '[]', description: 'JSON array of challenges addressed by the product (optional)', typeOptions: { rows: 3 }, }, { displayName: 'Customer Benefits (JSON Array)', name: 'customerBenefits', type: 'json', default: '[]', description: 'JSON array of customer benefits (optional)', typeOptions: { rows: 3 }, }, { displayName: 'Differentiated Value (JSON Array)', name: 'differentiatedValue', type: 'json', default: '[]', description: 'JSON array of differentiated value propositions (optional)', typeOptions: { rows: 3 }, }, { displayName: 'Status Quo (JSON Array)', name: 'statusQuo', type: 'json', default: '[]', description: 'JSON array of status quo descriptions (optional)', typeOptions: { rows: 3 }, }, { displayName: 'Custom Fields (JSON Array)', name: 'customFields', type: 'json', default: '[]', description: 'JSON array of custom fields: [{"title": "field", "value": ["item1", "item2"]}] (optional)', typeOptions: { rows: 5 } }, ]; const displayOptions = { show: { resource: ['product'], operation: ['update'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const body = {}; body.oId = this.getNodeParameter('oId', itemIndex); if (!body.oId) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Product OId is required to update a product.', { itemIndex }); } body.name = this.getNodeParameter('name', itemIndex); body.type = this.getNodeParameter('type', itemIndex); body.description = this.getNodeParameter('description', itemIndex); body.summary = this.getNodeParameter('summary', itemIndex); body.internalName = this.getNodeParameter('internalName', itemIndex); body.primaryUrl = this.getNodeParameter('primaryUrl', itemIndex); body.capabilities = utils_1.parseJsonParameter.call(this, 'capabilities', itemIndex, '[]'); body.challengesAddressed = utils_1.parseJsonParameter.call(this, 'challengesAddressed', itemIndex, '[]'); body.customerBenefits = utils_1.parseJsonParameter.call(this, 'customerBenefits', itemIndex, '[]'); body.differentiatedValue = utils_1.parseJsonParameter.call(this, 'differentiatedValue', itemIndex, '[]'); body.statusQuo = utils_1.parseJsonParameter.call(this, 'statusQuo', itemIndex, '[]'); body.customFields = utils_1.parseJsonParameter.call(this, 'customFields', itemIndex, '[]'); Object.keys(body).forEach(key => (body[key] === undefined) && delete body[key]); const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'PUT', '/api/v2/product/update', body); const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } }); return [executionData]; } //# sourceMappingURL=update.operation.js.map