UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

91 lines 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; exports.execute = execute; const utilities_1 = require("../../../../utils/utilities"); const descriptions_1 = require("../../descriptions"); const transport_1 = require("../../transport"); const properties = [ { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased displayName: 'Create in', name: 'location', type: 'options', options: [ { name: 'Case', value: 'case', }, { name: 'Knowledge Base', value: 'knowledgeBase', }, ], default: 'case', }, { ...descriptions_1.caseRLC, displayOptions: { show: { location: ['case'], }, }, }, { displayName: 'Title', name: 'title', type: 'string', default: '', required: true, }, { displayName: 'Category', name: 'category', type: 'string', default: '', required: true, }, { displayName: 'Content', name: 'content', type: 'string', default: '', required: true, typeOptions: { rows: 2, }, }, ]; const displayOptions = { show: { resource: ['page'], operation: ['create'], }, }; exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties); async function execute(i) { let responseData = []; const location = this.getNodeParameter('location', i); const title = this.getNodeParameter('title', i); const category = this.getNodeParameter('category', i); const content = this.getNodeParameter('content', i); let endpoint; if (location === 'case') { const caseId = this.getNodeParameter('caseId', i, '', { extractValue: true }); endpoint = `/v1/case/${caseId}/page`; } else { endpoint = '/v1/page'; } const body = { title, category, content, }; responseData = await transport_1.theHiveApiRequest.call(this, 'POST', endpoint, body); const executionData = this.helpers.constructExecutionMetaData((0, utilities_1.wrapData)(responseData), { itemData: { item: i }, }); return executionData; } //# sourceMappingURL=create.operation.js.map