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.

129 lines 4.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exportedProperties = void 0; exports.execute = execute; const OctaveApiRequest_1 = require("../../transport/OctaveApiRequest"); const utils_1 = require("../utils"); const properties = [ { displayName: 'Return All', name: 'returnAll', type: 'boolean', default: true, description: 'Whether to return all results or only up to a given limit', }, { displayName: 'Limit', name: 'limit', type: 'number', displayOptions: { show: { returnAll: [false], }, }, typeOptions: { minValue: 1, }, default: 50, description: 'Max number of results to return', }, { displayName: 'Offset', name: 'offset', type: 'number', default: 0, description: 'Offset of the results to return', }, { displayName: 'Query', name: 'query', type: 'string', default: '', description: 'Text search query for agents', }, { displayName: 'Agent Type', name: 'agentType', type: 'options', options: [ { name: 'All', value: '' }, { name: 'Call Prep', value: 'CALL_PREP' }, { name: 'Content', value: 'CONTENT' }, { name: 'Email', value: 'EMAIL' }, { name: 'Enrich Company', value: 'ENRICH_COMPANY' }, { name: 'Enrich Person', value: 'ENRICH_PERSON' }, { name: 'Prospector', value: 'PROSPECTOR' }, { name: 'Qualify Company', value: 'QUALIFY_COMPANY' }, { name: 'Qualify Person', value: 'QUALIFY_PERSON' }, ], default: '', description: 'Filter agents by type', }, { displayName: 'Order By Field', name: 'orderField', type: 'options', options: [ { name: 'Created At', value: 'createdAt' }, { name: 'Updated At', value: 'updatedAt' }, ], default: 'createdAt', description: 'Field to order the agents by', }, { displayName: 'Order Direction', name: 'orderDirection', type: 'options', options: [ { name: 'Descending', value: 'DESC' }, { name: 'Ascending', value: 'ASC' }, ], default: 'DESC', description: 'Direction to order the agents by', }, ]; const displayOptions = { show: { resource: ['agent'], operation: ['list'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const qs = {}; let responseDataInner; let responseDataOuter; const returnAll = this.getNodeParameter('returnAll', itemIndex, true); qs.query = this.getNodeParameter('query', itemIndex, undefined); const agentType = this.getNodeParameter('agentType', itemIndex, undefined); if (agentType) qs.type = agentType; qs.orderField = this.getNodeParameter('orderField', itemIndex, 'createdAt'); qs.orderDirection = this.getNodeParameter('orderDirection', itemIndex, 'DESC'); Object.keys(qs).forEach(key => (qs[key] === undefined) && delete qs[key]); if (returnAll) { qs.limit = this.getNodeParameter('limit', itemIndex, 100); qs.offset = this.getNodeParameter('offset', itemIndex, 0); responseDataInner = await OctaveApiRequest_1.octaveApiRequestListAll.call(this, 'GET', '/api/v2/agents/list', qs); const responseWithMetadata = { data: responseDataInner, _metadata: { message: "Metadata not available for returnAll operations - data aggregated from multiple API calls" } }; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseWithMetadata), { itemData: { item: itemIndex } }); return [executionData]; } else { qs.limit = this.getNodeParameter('limit', itemIndex, 10); qs.offset = this.getNodeParameter('offset', itemIndex, 0); responseDataOuter = await OctaveApiRequest_1.octaveApiRequest.call(this, 'GET', '/api/v2/agents/list', {}, qs); const responseWithMetadata = { data: (responseDataOuter === null || responseDataOuter === void 0 ? void 0 : responseDataOuter.data) !== undefined ? responseDataOuter.data : responseDataOuter, _metadata: responseDataOuter === null || responseDataOuter === void 0 ? void 0 : responseDataOuter._metadata }; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseWithMetadata), { itemData: { item: itemIndex } }); return [executionData]; } } //# sourceMappingURL=list.operation.js.map