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.
65 lines • 2.77 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: 'Name',
name: 'name',
type: 'string',
required: true,
default: '',
description: 'Name of the reference',
},
{
displayName: 'Product OID',
name: 'productOId',
type: 'string',
required: true,
default: '',
description: 'The OId of the product this reference is associated with',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
typeOptions: {
rows: 4,
},
default: '',
description: 'Description of the reference',
},
{
displayName: 'Data (JSON Format)',
name: 'dataJson',
type: 'json',
default: '{}',
description: 'JSON object containing reference data. Refer to Octave API docs for schema.',
placeholder: '{\n "howTheyMakeMoney": "Example explanation...",\n "howTheyUseProduct": "Details on product usage...",\n "howTheyBenefitFromProduct": "Benefits derived...",\n "emailSnippets": ["Snippet 1", "Snippet 2"],\n "customFields": [{ \"title\": \"Custom Field Name\", \"value\": [\"Value1\"] }]\n}',
},
];
const displayOptions = {
show: {
resource: ['reference'],
operation: ['create'],
},
};
exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties);
async function execute(itemIndex) {
const body = {};
body.name = this.getNodeParameter('name', itemIndex);
body.productOId = this.getNodeParameter('productOId', itemIndex);
if (!body.name || !body.productOId) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Name and Product OId are required for creating a reference.', { itemIndex });
}
body.description = this.getNodeParameter('description', itemIndex);
body.data = utils_1.parseJsonParameter.call(this, 'dataJson', itemIndex, '{}');
Object.keys(body).forEach(key => (body[key] === undefined || (typeof body[key] === 'object' && Object.keys(body[key]).length === 0 && key === 'data')) && delete body[key]);
const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/references/create', body);
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } });
return [executionData];
}
//# sourceMappingURL=create.operation.js.map