Overview
TheBaseMember class is the abstract base class that all member types extend. It provides common functionality for execution, validation, caching, retry logic, and lifecycle hooks.
Abstract Class
BaseMember and implement the execute() method.
Constructor
Member configuration options
Unique member name
Member type:
Think, Function, Data, APIType-specific configuration
Caching configuration
Retry configuration
Execution timeout in milliseconds
Additional metadata
Abstract Methods
execute()
Execute the member logic (must be implemented).Input data for execution
Promise<any> - Execution result
Example Implementation:
Lifecycle Hooks
beforeExecute()
Called before execute(), useful for validation and setup.afterExecute()
Called after execute(), useful for cleanup and post-processing.Output from execute()
Promise<any> - Transformed output
Example:
onError()
Called when execute() throws an error.Error that occurred
Input that caused error
Properties
name
type
Think, Function, Data, API.
config
timeout
metadata
Caching
Cache Configuration
getCacheKey()
Generate cache key for input.shouldCache()
Determine if result should be cached.Retry Logic
Retry Configuration
shouldRetry()
Determine if execution should be retried.Validation
validateInput()
Validate input before execution.validateOutput()
Validate output after execution.Context Access
getContext()
Access execution context.Creating Custom Members
Basic Custom Member
With Lifecycle Hooks
With Caching
Testing
Best Practices
- Implement all lifecycle hooks - For robust error handling
- Validate input - Fail fast on bad data
- Use descriptive names - Clear member identification
- Handle errors gracefully - Provide context
- Cache when appropriate - Improve performance
- Set reasonable timeouts - Prevent hanging
- Log important events - Aid debugging
- Test thoroughly - All code paths
- Document behavior - Clear expectations
- Keep execute() focused - Single responsibility

