import { INodeType , INodeTypeData , INodeTypeDescription , INodeTypes , INodeVersionedType , NodeHelpers , } from 'n8n-workflow' ; class NodeTypesClass implements INodeTypes { nodeTypes : INodeTypeData = { } ; async init ( nodeTypes ) { for ( const nodeTypeData of Object . values ( nodeTypes ) ) { const nodeType = NodeHelpers . getVersionedNodeType ( nodeTypeData . type ) ; const applyParameters = 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 ; } /**
     * Variant of `getByNameAndVersion` that includes the node's source path, used to locate a node's translations.
     */ getWithSourcePath ( nodeTypeName , version ) { const nodeType = this . nodeTypes [ nodeTypeName ] ; if ( ! nodeType ) { throw new Error ( `Unknown node type: ${ nodeTypeName }` ) ; } const { description } = NodeHelpers . getVersionedNodeType ( nodeType . type , version ) ; return { description : { ... description } , sourcePath : nodeType . sourcePath } ; } getByNameAndVersion ( nodeType , version ? ) { if ( this . nodeTypes [ nodeType ] === undefined ) { throw new Error ( `The node-type "${ nodeType }" is not known!` ) ; } return NodeHelpers . getVersionedNodeType ( this . nodeTypes [ nodeType ] . type , version ) ; } } let nodeTypesInstance ; export function NodeTypes ( ) { if ( nodeTypesInstance === undefined ) { nodeTypesInstance = new NodeTypesClass ( ) ; } return nodeTypesInstance ; }