UNPKG

n8n

Version:

n8n Workflow Automation Tool

38 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkflowCredentials = void 0; const _1 = require("."); async function WorkflowCredentials(nodes) { const returnCredentials = {}; let node; let type; let nodeCredentials; let foundCredentials; for (node of nodes) { if (node.disabled === true || !node.credentials) { continue; } for (type of Object.keys(node.credentials)) { if (!returnCredentials[type]) { returnCredentials[type] = {}; } nodeCredentials = node.credentials[type]; if (!nodeCredentials.id) { throw new Error(`Credentials with name "${nodeCredentials.name}" for type "${type}" miss an ID.`); } if (!returnCredentials[type][nodeCredentials.id]) { foundCredentials = await _1.Db.collections.Credentials.findOne({ id: nodeCredentials.id, type, }); if (!foundCredentials) { throw new Error(`Could not find credentials for type "${type}" with ID "${nodeCredentials.id}".`); } returnCredentials[type][nodeCredentials.id] = foundCredentials; } } } return returnCredentials; } exports.WorkflowCredentials = WorkflowCredentials; //# sourceMappingURL=WorkflowCredentials.js.map