Boolean Control
Boolean controls provide a simple toggle interface for boolean values (true/false). They're ideal for enabling or disabling features, setting configuration flags, and any scenario where you need a clear on/off state.
Basic Usage
import * as i from '@xentom/integration-framework';
// Simple boolean toggle
i.controls.boolean({
label: 'Enable Notifications',
default: true,
});
// With description
i.controls.boolean({
label: 'Debug Mode',
description: 'Enable detailed logging for troubleshooting',
default: false,
});Configuration Options
Prop
Type
Common Use Cases
Feature Toggles
// Environment variable for global feature toggle
DEBUG_MODE: i.env({
control: i.controls.boolean({
label: 'Debug Mode',
description: 'Enable debug logging and verbose output',
default: false,
}),
});
// Node input for per-operation toggle
enableRetry: i.pins.data({
control: i.controls.boolean({
label: 'Enable Retry',
description: 'Automatically retry failed requests',
default: true,
}),
});API Configuration
// SSL/TLS settings
useHttps: i.pins.data({
control: i.controls.boolean({
label: 'Use HTTPS',
description: 'Enable secure connection (recommended)',
default: true,
}),
});
// Validation options
strictValidation: i.pins.data({
control: i.controls.boolean({
label: 'Strict Validation',
description: 'Enforce strict data validation rules',
default: false,
}),
});Data Processing Options
// Format settings
includeMetadata: i.pins.data({
control: i.controls.boolean({
label: 'Include Metadata',
description: 'Add timestamp and source information to output',
default: false,
}),
});
// Transform options
normalizeData: i.pins.data({
control: i.controls.boolean({
label: 'Normalize Data',
description: 'Convert all text to lowercase and trim whitespace',
default: true,
}),
});Usage in Nodes
Boolean controls work seamlessly in both environment variables and node pins:
export default i.integration({
env: {
// Global setting for the entire integration
ENABLE_CACHING: i.env({
control: i.controls.boolean({
label: 'Enable Caching',
description: 'Cache API responses to improve performance',
default: true,
}),
}),
},
nodes: {
apiCall: i.nodes.action({
inputs: {
// Per-node setting
followRedirects: i.pins.data({
control: i.controls.boolean({
label: 'Follow Redirects',
description: 'Automatically follow HTTP redirects',
default: true,
}),
}),
validateResponse: i.pins.data({
control: i.controls.boolean({
label: 'Validate Response',
description: 'Validate API response against expected schema',
default: false,
}),
}),
},
async run({ inputs, next, state }) {
const options = {
followRedirects: inputs.followRedirects,
validateResponse: inputs.validateResponse,
};
// Use the boolean values in your logic
if (options.followRedirects) {
// Configure redirect handling
}
if (options.validateResponse) {
// Add response validation
}
// Continue with API call...
next({ success: true });
},
}),
},
});Conditional Logic
Boolean controls are particularly useful for conditional execution paths:
conditionalProcessor: i.nodes.action({
inputs: {
enableProcessing: i.pins.data({
control: i.controls.boolean({
label: 'Enable Processing',
default: true,
}),
}),
data: i.pins.data({
control: i.controls.text({
placeholder: 'Enter data to process...',
}),
}),
},
outputs: {
processed: i.pins.data(),
skipped: i.pins.data(),
},
run({ inputs, next }) {
if (inputs.enableProcessing) {
// Process the data
const result = processData(inputs.data);
next({ processed: result });
} else {
// Skip processing
next({ skipped: inputs.data });
}
},
});Best Practices
Clear Labels
Use descriptive labels that clearly indicate what the boolean controls:
// Good - Clear and specific
enableEmailNotifications: i.pins.data({
control: i.controls.boolean({
label: 'Send Email Notifications',
description: 'Email users when the process completes',
}),
});
// Avoid - Vague or unclear
toggle: i.pins.data({
control: i.controls.boolean({
label: 'Enable', // Enable what?
}),
});Sensible Defaults
Choose default values that represent the most common or safest option:
// Security-related settings default to safe option
enableCors: i.pins.data({
control: i.controls.boolean({
label: 'Enable CORS',
description: 'Allow cross-origin requests',
default: false, // Default to secure
}),
});
// User experience settings default to better experience
showProgressBar: i.pins.data({
control: i.controls.boolean({
label: 'Show Progress Bar',
description: 'Display progress during long operations',
default: true, // Default to better UX
}),
});Helpful Descriptions
Provide context about what the boolean does and when to use it:
batchProcessing: i.pins.data({
control: i.controls.boolean({
label: 'Batch Processing',
description:
'Process multiple items together for better performance. Disable for real-time processing.',
default: true,
}),
});Integration with Other Controls
Boolean controls often work well alongside other control types:
// Enable/disable based on boolean state
cacheSettings: i.pins.data({
control: i.controls.boolean({
label: 'Enable Caching',
default: false
})
}),
// This would typically be conditional in the UI
cacheTimeout: i.pins.data({
control: i.controls.select({
label: 'Cache Timeout',
options: [
{ value: 300, label: '5 minutes' },
{ value: 900, label: '15 minutes' },
{ value: 3600, label: '1 hour' }
]
}),
optional: true // Only show when caching is enabled
})Boolean controls provide a simple but powerful way to make your integrations configurable and adaptable to different use cases while maintaining a clean and intuitive user interface.
Number Control
Number controls provide a numeric input field for integer and decimal values. They support minimum and maximum bounds, step increments, and placeholder text, making them ideal for timeouts, limits, counts, and any scenario where users need to supply a precise numeric value.
Select Control
Select controls provide a dropdown interface for choosing from a predefined set of options. They support both static option lists and dynamic options that are fetched asynchronously, making them ideal for configuration choices and API-driven selections.