mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
110 lines
2.1 KiB
TypeScript
110 lines
2.1 KiB
TypeScript
|
import {
|
||
|
INodeType,
|
||
|
INodeTypes,
|
||
|
INodeTypesObject,
|
||
|
} from '../src';
|
||
|
|
||
|
class NodeTypesClass implements INodeTypes {
|
||
|
|
||
|
nodeTypes: INodeTypesObject = {
|
||
|
'test.set': {
|
||
|
description: {
|
||
|
displayName: 'Set',
|
||
|
name: 'set',
|
||
|
group: ['input'],
|
||
|
version: 1,
|
||
|
description: 'Sets a value',
|
||
|
defaults: {
|
||
|
name: 'Set',
|
||
|
color: '#0000FF',
|
||
|
},
|
||
|
inputs: ['main'],
|
||
|
outputs: ['main'],
|
||
|
properties: [
|
||
|
{
|
||
|
displayName: 'Value1',
|
||
|
name: 'value1',
|
||
|
type: 'string',
|
||
|
default: 'default-value1',
|
||
|
},
|
||
|
{
|
||
|
displayName: 'Value2',
|
||
|
name: 'value2',
|
||
|
type: 'string',
|
||
|
default: 'default-value2',
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
'test.setMulti': {
|
||
|
description: {
|
||
|
displayName: 'Set Multi',
|
||
|
name: 'setMulti',
|
||
|
group: ['input'],
|
||
|
version: 1,
|
||
|
description: 'Sets multiple values',
|
||
|
defaults: {
|
||
|
name: 'Set Multi',
|
||
|
color: '#0000FF',
|
||
|
},
|
||
|
inputs: ['main'],
|
||
|
outputs: ['main'],
|
||
|
properties: [
|
||
|
{
|
||
|
displayName: 'Values',
|
||
|
name: 'values',
|
||
|
type: 'fixedCollection',
|
||
|
typeOptions: {
|
||
|
multipleValues: true,
|
||
|
},
|
||
|
default: {},
|
||
|
options: [
|
||
|
{
|
||
|
name: 'string',
|
||
|
displayName: 'String',
|
||
|
values: [
|
||
|
{
|
||
|
displayName: 'Name',
|
||
|
name: 'name',
|
||
|
type: 'string',
|
||
|
default: 'propertyName',
|
||
|
placeholder: 'Name of the property to write data to.',
|
||
|
},
|
||
|
{
|
||
|
displayName: 'Value',
|
||
|
name: 'value',
|
||
|
type: 'string',
|
||
|
default: '',
|
||
|
placeholder: 'The string value to write in the property.',
|
||
|
},
|
||
|
]
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
};
|
||
|
|
||
|
async init(nodeTypes: INodeTypesObject): Promise<void> { }
|
||
|
|
||
|
getAll(): INodeType[] {
|
||
|
return Object.values(this.nodeTypes);
|
||
|
}
|
||
|
|
||
|
getByName(nodeType: string): INodeType {
|
||
|
return this.nodeTypes[nodeType];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let nodeTypesInstance: NodeTypesClass | undefined;
|
||
|
|
||
|
export function NodeTypes(): NodeTypesClass {
|
||
|
if (nodeTypesInstance === undefined) {
|
||
|
nodeTypesInstance = new NodeTypesClass();
|
||
|
nodeTypesInstance.init({});
|
||
|
}
|
||
|
|
||
|
return nodeTypesInstance;
|
||
|
}
|