- Fix has_unique flag reading from field definition (was scanning fragment fields) - Implement duplicate validation in CLI and TUI backends - Add item counter update in Web backend after add/delete operations - Refactor Web JavaScript: remove global constants, use closure-based state per group - Store repeating group config in data-* attributes instead of global variables - Update documentation and examples with unique = true attribute - All backends now enforce unique items validation consistently
120 lines
3.4 KiB
Plaintext
120 lines
3.4 KiB
Plaintext
# Nickel Schema: Array Types with RepeatingGroup Integration
|
|
#
|
|
# This example demonstrates how TypeDialog's RepeatingGroup field type
|
|
# integrates with Nickel's Array(Record) types for managing collections
|
|
# of structured data.
|
|
|
|
{
|
|
# ========================================================
|
|
# Record Types (Reusable Structures)
|
|
# ========================================================
|
|
|
|
# UDP Tracker listener configuration
|
|
TrackerUdp = {
|
|
# Bind address for UDP listener (e.g., "0.0.0.0:6969")
|
|
bind_address | String,
|
|
|
|
# Number of worker threads (optional)
|
|
workers | Number | default = 4,
|
|
},
|
|
|
|
# HTTP Tracker listener configuration
|
|
TrackerHttp = {
|
|
# Bind address for HTTP listener (e.g., "0.0.0.0:7070")
|
|
bind_address | String,
|
|
|
|
# Protocol: http or https
|
|
protocol | [| 'http, 'https |] | default = 'http,
|
|
|
|
# Number of worker threads (optional)
|
|
workers | Number | default = 8,
|
|
},
|
|
|
|
# API Endpoint configuration
|
|
ApiEndpoint = {
|
|
# Endpoint path (e.g., "/api/v1")
|
|
path | String,
|
|
|
|
# Enable authentication on this endpoint
|
|
require_auth | Bool | default = true,
|
|
|
|
# Rate limit (requests per minute)
|
|
rate_limit | Number | default = 100,
|
|
},
|
|
|
|
# User/Account configuration
|
|
User = {
|
|
# Username (must be alphanumeric with underscores)
|
|
username | String,
|
|
|
|
# Email address
|
|
email | String,
|
|
|
|
# User role
|
|
role | [| 'admin, 'moderator, 'user |] | default = 'user,
|
|
|
|
# Is account active
|
|
active | Bool | default = true,
|
|
},
|
|
|
|
# ========================================================
|
|
# Main Configuration (Maps to Form)
|
|
# ========================================================
|
|
|
|
Config = {
|
|
# ~~~~~ Tracker Configuration ~~~~~
|
|
|
|
# Tracker mode: public or private
|
|
tracker_mode | [| 'public, 'private |],
|
|
|
|
# Array of UDP tracker listeners
|
|
# In TypeDialog: RepeatingGroup field with fragment defining TrackerUdp fields
|
|
# User can add/edit/delete multiple UDP trackers
|
|
udp_trackers | Array TrackerUdp | optional,
|
|
|
|
# Array of HTTP tracker listeners
|
|
# In TypeDialog: RepeatingGroup field with fragment defining TrackerHttp fields
|
|
http_trackers | Array TrackerHttp | optional,
|
|
|
|
# ~~~~~ API Configuration ~~~~~
|
|
|
|
# Admin API token for authentication
|
|
api_token | String,
|
|
|
|
# API port number (1024-65535)
|
|
api_port | Number
|
|
| std.number.is_between 1024 65535 ?
|
|
| "API port must be between 1024 and 65535",
|
|
|
|
# Array of API endpoints exposed by the service
|
|
# In TypeDialog: RepeatingGroup field with fragment defining ApiEndpoint fields
|
|
api_endpoints | Array ApiEndpoint | optional,
|
|
|
|
# ~~~~~ User Management ~~~~~
|
|
|
|
# Array of users/accounts
|
|
# In TypeDialog: RepeatingGroup field with fragment defining User fields
|
|
# Admin can add/edit/delete user accounts
|
|
users | Array User | optional,
|
|
|
|
# ~~~~~ Optional Features ~~~~~
|
|
|
|
# Enable metrics collection
|
|
enable_metrics | Bool | default = false,
|
|
|
|
# Enable logging (if enabled, requires log_level)
|
|
enable_logging | Bool | default = true,
|
|
|
|
# Log level if logging is enabled
|
|
log_level | [| 'debug, 'info, 'warn, 'error |]
|
|
| default = 'info
|
|
| std.function.optional_if (! enable_logging),
|
|
},
|
|
|
|
# ========================================================
|
|
# Export the main configuration as default
|
|
# ========================================================
|
|
|
|
Config
|
|
}
|