@metreeca/blue - v0.10.0
    Preparing search index...

    Module value

    Composite shapes and cardinality factories.

    Defines the shape hierarchy for describing the expected structure of linked data values, along with cardinality factories for constraining how many values a property may hold.

    Shape Hierarchy

    Shape hierarchy

    Type Inference

    Two companion types project a shape into the relevant TypeScript view:

    • Schema — the complete template declared by the shape, describing every property and carrying cardinality-driven optionality both on the value types and, for properties admitting absence, as an optional key (template side).
    • State — the runtime state value matching the template, recovered through the Instance; entries admitting absence may be undefined or omitted outright (state side).

    Ancillary helpers Resolved, Bounds, and Boxed factor the internal projections (narrowing the eager unwrap of a Lazy shape to the Shape or RangeShape bound, resolving union branches, conditioning a shape's model on cardinality, and boxing values into singleton tuples for multi-valued ranges) and are exported for tests and downstream shape extensions.

    Factories

    • The cardinality factories wrap a shape in a SetShape with fixed bounds: required (exactly one), optional (at most one), repeatable (at least one), and multiple (any number).
    • cardinality is the general form, returning a factory for an arbitrary minCount / maxCount pair that the four named factories specialise.

    Utilities

    • eager resolves a Lazy shape factory to its concrete Shape, caching results and flattening ResourceShape entries; a resolved RangeShape passes through unchanged.
    • model extracts the runtime Schema of a shape, an ergonomic shortcut for eager(shape).model.
    • effective resolves the effective RangeShape type for a Probe against a Shape, or re-probes a previously resolved RangeShape whose bounds compose into the traversal, walking property paths through nested resources, branching across UnionShape variants at the entry or at any property range, and applying each transform pipe stage. It yields an atomic Trace string when the probe cannot be resolved or its transform pipe cannot be applied to any resolved variant.

    Type Aliases

    Shape

    Discriminated union of all value and union shapes.

    ValuesShape

    Discriminated union of all concrete value shapes, including those that always describe a set.

    ValueShape

    Discriminated union of value shapes that may describe either a scalar or a set.

    SetShape

    Shape for a cardinality-constrained value set.

    SetFactory

    Factory function returned by cardinality.

    RangeShape

    Resolved value range of a Probe.

    Schema

    Extracts the complete template declared by a shape.

    State

    Projects a shape to the runtime value type its values satisfy.

    Resolved

    Narrows the Eager unwrap of a Lazy shape to the Shape or RangeShape constraint, so downstream indexed access stays sound.

    Bounds

    Conditions a shape's model on cardinality bounds to produce the template-side value type.

    Boxed

    Boxes a value in a singleton tuple when cardinality admits multiple values.

    Functions

    eager

    Resolves a Lazy shape to its eager form, caching the result on repeated calls.

    model

    Extracts the deeply typed retrieval template from a Lazy shape.

    effective

    Resolve the effective RangeShape a Probe yields against a shape.

    multiple

    Creates a SetShape with no cardinality constraints (0..*).

    repeatable

    Creates a SetShape requiring at least one value (1..*).

    optional

    Creates a SetShape for at most one value (0..1).

    required

    Creates a SetShape for exactly one value (1..1).

    cardinality

    Creates a SetFactory with custom cardinality constraints.