Skip to content

Releases: davidesantangelo/node-red

Release list

v0.2.0

Choose a tag to compare

@davidesantangelo davidesantangelo released this 28 Oct 15:19

What's New

Structured Error Classes

Error handling is now much more robust and informative. All API errors now include contextual information to help you diagnose issues faster:

begin
  client.flows
rescue Node::Red::BadRequestError => e
  puts "Status: #{e.status}"        # => 400
  puts "Code: #{e.code}"             # => "invalid_request"
  puts "Details: #{e.details.inspect}" # => Full parsed response body
end

New error classes:

  • BadRequestError - Raised for HTTP 400 responses (malformed requests)
  • ConflictError - Raised for HTTP 409 responses (version conflicts)
  • UnexpectedResponseError - Raised for unexpected response types

Enhanced existing errors:

  • AuthenticationError - Now includes structured context (HTTP 401)
  • NotFoundError - Now includes structured context (HTTP 404)
  • ServerError - Now includes structured context (HTTP 5xx)

Comprehensive Test Coverage

Added extensive WebMock-backed RSpec tests covering:

  • ✅ Every Admin API endpoint (auth, flows, nodes, settings, diagnostics)
  • ✅ All error paths and edge cases
  • ✅ Authorization header handling
  • ✅ Empty response bodies
  • ✅ Invalid JSON responses
  • ✅ Various HTTP status codes

This ensures reliability and makes future contributions easier!

Improvements

Better Error Handling

The client now intelligently maps Node-RED response codes to dedicated exceptions:

  • 400 → BadRequestError
  • 401 → AuthenticationError
  • 404 → NotFoundError
  • 409 → ConflictError
  • 5xx → ServerError
  • Other unexpected responses → UnexpectedResponseError

Enhanced JSON Parsing

Response and error parsing now includes safeguards for:

  • Empty response bodies
  • Invalid JSON
  • Missing error fields
  • Malformed content

This prevents cryptic parsing errors and provides clearer diagnostics.

Updated Documentation

The README now includes advanced error-handling guidance with examples showing how to access error context for debugging.

Dependencies

Added webmock ~> 3.19 for HTTP request stubbing in tests.

Migration Guide

If you're upgrading from v0.1.0, no breaking changes were introduced! Your existing code will continue to work. However, you can now optionally access richer error information:

Before:

rescue Node::Red::ApiError => e
  puts e.message
end

After (optional enhancement):

rescue Node::Red::ApiError => e
  puts "Error: #{e.message}"
  puts "HTTP Status: #{e.status}"
  puts "Error Code: #{e.code}" if e.code
  puts "Details: #{e.details.inspect}" if e.details
end

Full Changelog: [View on GitHub](https://github.com/your-repo/node-red-ruby/compare/v0.1.0...v0.2.0)

v0.1.0

Choose a tag to compare

@davidesantangelo davidesantangelo released this 28 Oct 15:03

Added

Core Features

  • Initial release of Node-RED Admin HTTP API Ruby client
  • Complete implementation of all 21 Node-RED Admin API endpoints
  • Comprehensive RDoc documentation for all public methods

Authentication Support (3 endpoints)

  • auth_login - Get active authentication scheme
  • auth_token - Exchange credentials for access token with automatic token management
  • auth_revoke - Revoke access tokens

Settings & Diagnostics (2 endpoints)

  • settings - Get runtime settings and configuration
  • diagnostics - Get runtime diagnostics information

Flow Management (8 endpoints)

  • flows - Get active flow configuration
  • flows_state - Get flow runtime state
  • deploy_flows - Deploy complete flow configuration with revision support
  • set_flows_state - Start/stop flows at runtime
  • add_flow - Add individual flows to configuration
  • flow - Get specific flow configuration
  • update_flow - Update individual flow configuration
  • delete_flow - Delete individual flows

Node Management (8 endpoints)

  • nodes - List all installed node modules
  • install_node - Install new node modules from npm
  • node_module - Get node module information
  • update_node_module - Enable/disable node modules
  • delete_node_module - Remove node modules
  • node_set - Get node set information
  • update_node_set - Enable/disable node sets

Error Handling

  • ApiError - Base error class for all API errors
  • AuthenticationError - Raised on authentication failures (401)
  • NotFoundError - Raised when resources are not found (404)
  • ServerError - Raised on server errors (5xx)
  • Intelligent error message parsing from API responses

Developer Experience

  • Three comprehensive example files demonstrating usage:
    • examples/basic_usage.rb - Basic API operations
    • examples/flow_management.rb - Flow CRUD operations
    • examples/node_management.rb - Node module management
  • RSpec test suite with basic coverage
  • RuboCop configuration for code quality
  • Detailed README with usage examples for all endpoints
  • MIT License

Technical Details

  • Minimum Ruby version: 3.1.0
  • Zero external dependencies (uses only Ruby stdlib)
  • HTTP client built on Net::HTTP
  • JSON parsing with stdlib json
  • Automatic Bearer token management after authentication
  • Support for both HTTP and HTTPS connections

Notes

  • All dangerous operations (install/delete/enable/disable) are commented out in examples for safety
  • API follows Node-RED Admin API specification exactly
  • Fully compatible with Node-RED 1.0.0+