UNPKG

@apify/n8n-nodes-apify

Version:
45 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runTask = runTask; const n8n_workflow_1 = require("n8n-workflow"); const genericFunctions_1 = require("../../../resources/genericFunctions"); async function runTask(i) { var _a; const actorTaskId = this.getNodeParameter('actorTaskId', i, undefined, { extractValue: true, }); const input = this.getNodeParameter('customBody', i, {}); const waitForFinish = this.getNodeParameter('waitForFinish', i); const timeout = this.getNodeParameter('timeout', i, null); const memory = this.getNodeParameter('memory', i, null); const build = this.getNodeParameter('build', i, ''); if (!actorTaskId) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Task ID is required'); } const qs = {}; if (timeout != null) qs.timeout = timeout; if (memory != null) qs.memory = memory; if (build) qs.build = build; qs.waitForFinish = 0; const apiResult = await genericFunctions_1.apiRequest.call(this, { method: 'POST', uri: `/v2/actor-tasks/${actorTaskId}/runs`, body: input, qs, }); if (!((_a = apiResult === null || apiResult === void 0 ? void 0 : apiResult.data) === null || _a === void 0 ? void 0 : _a.id)) { throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: `Run ID not found after running the task`, }); } if (!waitForFinish) { return { json: { ...apiResult.data } }; } const runId = apiResult.data.id; const lastRunData = await genericFunctions_1.pollRunStatus.call(this, runId); return { json: { ...lastRunData } }; } //# sourceMappingURL=execute.js.map