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.
132 lines • 5.13 kB
JavaScript
;
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: 'Competitor OId',
name: 'oId',
type: 'string',
required: true,
default: '',
description: 'OId of the competitor to update',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of the competitor (optional)',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'Description of the competitor (optional)',
},
{
displayName: 'Internal Name',
name: 'internalName',
type: 'string',
default: '',
description: 'Internal name of the competitor (optional)',
},
{
displayName: 'Business Model (JSON Array)',
name: 'businessModel',
type: 'json',
default: '[]',
description: 'JSON array of business model descriptions (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Comparative Strengths (JSON Array)',
name: 'comparativeStrengths',
type: 'json',
default: '[]',
description: 'JSON array of comparative strengths (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Comparative Weaknesses (JSON Array)',
name: 'comparativeWeaknesses',
type: 'json',
default: '[]',
description: 'JSON array of comparative weaknesses (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Key Differentiators (JSON Array)',
name: 'keyDifferentiators',
type: 'json',
default: '[]',
description: 'JSON array of key differentiators (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Reasons We Win (JSON Array)',
name: 'reasonsWeWin',
type: 'json',
default: '[]',
description: 'JSON array of reasons we win against this competitor (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Customers We Won (JSON Array)',
name: 'customersWeWon',
type: 'json',
default: '[]',
description: 'JSON array of customers we won from this competitor (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Customers We Switched (JSON Array)',
name: 'customersWeSwitched',
type: 'json',
default: '[]',
description: 'JSON array of customers we switched to this competitor (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: ['competitor'],
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(), 'Competitor OId is required to update a competitor.', { itemIndex });
}
body.name = this.getNodeParameter('name', itemIndex);
body.description = this.getNodeParameter('description', itemIndex);
body.internalName = this.getNodeParameter('internalName', itemIndex);
body.businessModel = utils_1.parseJsonParameter.call(this, 'businessModel', itemIndex, '[]');
body.comparativeStrengths = utils_1.parseJsonParameter.call(this, 'comparativeStrengths', itemIndex, '[]');
body.comparativeWeaknesses = utils_1.parseJsonParameter.call(this, 'comparativeWeaknesses', itemIndex, '[]');
body.keyDifferentiators = utils_1.parseJsonParameter.call(this, 'keyDifferentiators', itemIndex, '[]');
body.reasonsWeWin = utils_1.parseJsonParameter.call(this, 'reasonsWeWin', itemIndex, '[]');
body.customersWeWon = utils_1.parseJsonParameter.call(this, 'customersWeWon', itemIndex, '[]');
body.customersWeSwitched = utils_1.parseJsonParameter.call(this, 'customersWeSwitched', 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/competitor/update', body);
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } });
return [executionData];
}
//# sourceMappingURL=update.operation.js.map