Skip to content

v0.1.2

@nshkrdotcom nshkrdotcom tagged this 23 Dec 03:02
This release introduces significant enhancements to the ChzEx type system,
bridging functional gaps with the reference Python implementation and providing
developers with more granular control over configuration structures. The update
focuses on complex type definitions, schema versioning flexibility, and user
experience improvements in CLI interactions.

Key Features and Changes:

1. Map Schema Support
   Introduced the `{:map_schema, map}` type definition, enabling the specification
   of typed maps with distinct keys and value types, analogous to Python's
   TypedDict.
   - Fields within a map schema are now expanded in the Blueprint, permitting
     individual addressing via CLI arguments (e.g., `server.options.timeout=50`).
   - Added support for required and optional field markers using the syntax
     `{:type, :required}` or `{:type, :optional}`.
   - Implemented deep validation logic to ensure map values conform to the
     specified schema structure.

2. Heterogeneous Tuple Support
   Added the `{:tuple, [type1, type2, ...]}` type definition for fixed-size
   tuples with specific types at each position.
   - Tuple elements are expanded as indexed parameters in the Blueprint,
     allowing positional assignment (e.g., `coordinates.0=10`, `coordinates.1=20`).
   - Full type checking and casting are applied per position.

3. Version Suffix Support
   Schema version strings now support suffixes to facilitate iteration tracking
   without breaking hash validation.
   - The validation logic now splits the version string on the first hyphen.
   - A version string like "a1b2c3d4-v2" validates successfully against the
     hash "a1b2c3d4", allowing developers to tag schema iterations explicitly.

4. Polymorphism Control
   Added the `meta_factory: :disabled` option to the `field/3` macro.
   - This explicitly disables polymorphic behavior for a field, ensuring that
     the base type is used regardless of input triggers that would normally
     invoke a factory.

5. User Experience Improvements
   - The `get_help/1` function now generates a conspicuous warning header when
     required parameters are missing, improving feedback loops during CLI usage.
   - Help text formatting has been refined to better display default values and
     types.
   - Error messages for extraneous arguments now include layer attribution,
     helping identify the source of invalid configuration (e.g., "from command line").

Internal Implementation Details:
- Refactored `ChzEx.Schema` to automatically convert ChzEx-specific internal types
  (map schemas and tuples) into Ecto-compatible types (`:map` and `:any`) during
  schema definition. This ensures that `Ecto.Schema` definitions remain valid
  while preserving strict type checking within the ChzEx lifecycle.
- Added comprehensive test suites for map schemas, heterogeneous tuples, and
  Computed reference cycle detection.
- Included a new example script `examples/advanced_types.exs` demonstrating the
  usage of these new type system features.
Assets 2
Loading