@realvendex/pi-config
v1.0.0
Published
Configuration management and schema validation for pi.dev extensions
Maintainers
Readme
@realvendex/pi-config
Configuration management and schema validation for pi.dev extensions.
Installation
pi install npm:@realvendex/pi-configWhat It Does
Provides three tools for managing extension configurations:
- Schema validation — validate config objects against TypeBox-compatible schemas
- Multi-format loading — load configs from JSON, YAML, and TOML files with auto-detection
- Precedence merging — merge config layers with clear priority: defaults < file < env < CLI args
Tools
validate-config
Validate a configuration object against a TypeBox-compatible schema.
Parameters:
config(object, required) — Configuration object to validateschema(object, required) — TypeBox-compatible schema definitionstrict(boolean, optional) — Reject unknown properties (default: false)
Example:
Use validate-config with config={"port": 3000} and schema={"type":"object","properties":{"port":{"type":"number"}}}load-config
Load configuration from a file with auto-detect or explicit format.
Parameters:
path(string, required) — Path to config file (.json, .yaml, .yml, .toml)format(string, optional) — Override auto-detection: "json", "yaml", or "toml"
Example:
Use load-config with path="./config.yaml"merge-config
Merge multiple config layers with precedence: defaults < file < env < CLI args.
Parameters:
defaults(object, optional) — Default values (lowest priority)file(object, optional) — File-based configurationenv(object, optional) — Environment variable overridesargs(object, optional) — CLI argument overrides (highest priority)
Example:
Use merge-config with defaults={"port":3000} and args={"port":8080}Resources
License
MIT
