n8n
Version:
n8n Workflow Automation Tool
43 lines • 1.55 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeTypes = void 0;
const n8n_workflow_1 = require("n8n-workflow");
class NodeTypesClass {
constructor() {
this.nodeTypes = {};
}
async init(nodeTypes) {
for (const nodeTypeData of Object.values(nodeTypes)) {
const nodeType = n8n_workflow_1.NodeHelpers.getVersionedTypeNode(nodeTypeData.type);
const applyParameters = n8n_workflow_1.NodeHelpers.getSpecialNodeParameters(nodeType);
if (applyParameters.length) {
nodeType.description.properties.unshift(...applyParameters);
}
}
this.nodeTypes = nodeTypes;
}
getAll() {
return Object.values(this.nodeTypes).map((data) => data.type);
}
getByName(nodeType) {
if (this.nodeTypes[nodeType] === undefined) {
throw new Error(`The node-type "${nodeType}" is not known!`);
}
return this.nodeTypes[nodeType].type;
}
getByNameAndVersion(nodeType, version) {
if (this.nodeTypes[nodeType] === undefined) {
throw new Error(`The node-type "${nodeType}" is not known!`);
}
return n8n_workflow_1.NodeHelpers.getVersionedTypeNode(this.nodeTypes[nodeType].type, version);
}
}
let nodeTypesInstance;
function NodeTypes() {
if (nodeTypesInstance === undefined) {
nodeTypesInstance = new NodeTypesClass();
}
return nodeTypesInstance;
}
exports.NodeTypes = NodeTypes;
//# sourceMappingURL=NodeTypes.js.map
;