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.
130 lines • 4.9 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: 'Mode',
name: 'mode',
type: 'options',
options: [
{ name: 'Text', value: 'text', description: 'Create from plain text content (sync)' },
{ name: 'File (Base64)', value: 'file', description: 'Create from base64 encoded file (sync)' },
{ name: 'URL', value: 'url', description: 'Create from URL (async — poll status)' },
{ name: 'Google Drive', value: 'drive', description: 'Create from Google Drive file ID (async)' },
],
default: 'text',
description: 'How the resource will be created',
},
{
displayName: 'Text',
name: 'text',
type: 'string',
default: '',
description: 'The text content of the resource',
typeOptions: { rows: 8 },
displayOptions: { show: { mode: ['text'] } },
},
{
displayName: 'File (Base64)',
name: 'file',
type: 'string',
default: '',
description: 'Base64 encoded file content',
typeOptions: { rows: 4 },
displayOptions: { show: { mode: ['file'] } },
},
{
displayName: 'Filename',
name: 'filename',
type: 'string',
default: '',
description: 'Original filename including extension',
displayOptions: { show: { mode: ['file'] } },
},
{
displayName: 'Content Type',
name: 'contentType',
type: 'string',
default: '',
description: 'MIME type of the file (e.g. application/pdf)',
displayOptions: { show: { mode: ['file'] } },
},
{
displayName: 'URL',
name: 'url',
type: 'string',
default: '',
description: 'URL to crawl and index',
displayOptions: { show: { mode: ['url'] } },
},
{
displayName: 'Drive File ID',
name: 'driveFileId',
type: 'string',
default: '',
description: 'Google Drive file ID',
displayOptions: { show: { mode: ['drive'] } },
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Display name for the resource (optional)',
},
{
displayName: 'Metadata (JSON)',
name: 'metadata',
type: 'json',
default: '{}',
description: 'Optional metadata to attach to the resource',
typeOptions: { rows: 3 },
},
];
const displayOptions = {
show: {
resource: ['resource'],
operation: ['create'],
},
};
exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties);
async function execute(itemIndex) {
const mode = this.getNodeParameter('mode', itemIndex);
const body = { mode };
if (mode === 'text') {
body.text = this.getNodeParameter('text', itemIndex);
if (!body.text)
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Text is required for text mode.', { itemIndex });
}
else if (mode === 'file') {
body.file = this.getNodeParameter('file', itemIndex);
body.filename = this.getNodeParameter('filename', itemIndex);
body.contentType = this.getNodeParameter('contentType', itemIndex);
if (!body.file || !body.filename || !body.contentType) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'File, filename, and contentType are required for file mode.', { itemIndex });
}
}
else if (mode === 'url') {
body.url = this.getNodeParameter('url', itemIndex);
if (!body.url)
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'URL is required for url mode.', { itemIndex });
}
else if (mode === 'drive') {
body.driveFileId = this.getNodeParameter('driveFileId', itemIndex);
if (!body.driveFileId)
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Drive File ID is required for drive mode.', { itemIndex });
}
const name = this.getNodeParameter('name', itemIndex);
if (name)
body.name = name;
const metadata = utils_1.parseJsonParameter.call(this, 'metadata', itemIndex, '{}');
if (metadata && Object.keys(metadata).length > 0)
body.metadata = metadata;
const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/resource/create', body);
return [this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } })];
}
//# sourceMappingURL=create.operation.js.map