Custom Node Development
FluidGrids provides a powerful framework for developing custom nodes that extend the platform's capabilities. This guide will walk you through the process of creating, testing, and deploying custom nodes for your specific use cases.
Node Architecture
Core Components Understanding node structure:
A FluidGrids node consists of these key components:
- Node definition
- Input/output schema
- Processing logic
- Configuration interface
- Error handling
Node Types Available node categories:
FluidGrids supports various node types:
- Processing nodes
- Trigger nodes
- Integration nodes
- AI/ML nodes
- Custom logic nodes
Development Process
Setup Development Environment Prepare your environment:
# Create new node project
fluidgrids node create my-custom-node
# Install dependencies
cd my-custom-node
npm install
Node Implementation Basic node structure:
import { NodeDefinition, NodeProcessor } from '@fluidgrids/sdk';
export class MyCustomNode implements NodeProcessor {
async process(input: any, context: Context): Promise<any> {
// Implementation logic
return processedOutput;
}
}
export const nodeDefinition: NodeDefinition = {
type: 'custom',
name: 'my-custom-node',
version: '1.0.0',
// Additional configuration
};
Advanced Features
State Management Handle node state:
export class StatefulNode implements NodeProcessor {
private state: any;
async initialize(context: Context): Promise<void> {
this.state = await context.getState();
}
async process(input: any, context: Context): Promise<any> {
// Use this.state
await context.setState(newState);
return output;
}
}
Error Handling Implement robust error handling:
export class ResilientNode implements NodeProcessor {
async process(input: any, context: Context): Promise<any> {
try {
// Processing logic
} catch (error) {
context.logger.error('Processing failed', error);
throw new NodeError('PROCESSING_ERROR', error.message);
}
}
}
Testing Framework
Unit Testing Test your node implementation:
import { NodeTester } from '@fluidgrids/testing';
describe('MyCustomNode', () => {
const tester = new NodeTester(MyCustomNode);
it('processes input correctly', async () => {
const result = await tester
.withInput({ test: 'data' })
.execute();
expect(result).toMatchSnapshot();
});
});
Integration Testing Test in workflow context:
import { WorkflowTester } from '@fluidgrids/testing';
describe('Workflow Integration', () => {
const tester = new WorkflowTester();
it('integrates with workflow', async () => {
await tester
.withNode('my-custom-node')
.withWorkflow('test-workflow')
.execute();
});
});
Deployment Guide
Package and Deploy Deploy your custom node:
# Build node package
npm run build
# Publish to organization
fluidgrids node publish
# Deploy to production
fluidgrids node deploy --env production
Versioning Manage node versions:
- Semantic versioning
- Changelog maintenance
- Backward compatibility
- Migration support
- Version control
Best Practices
Development Guidelines Follow these best practices:
- Implement proper validation
- Add comprehensive logging
- Handle errors gracefully
- Write clear documentation
- Maintain test coverage
Getting Started
Begin developing custom nodes:
- Review Node SDK
- Explore Example Nodes
- Join Developer Community
For technical support, contact our Developer Support.