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

    Type Alias UnionShape<V>

    Discriminated type alternatives for polymorphic values.

    Variants are mutually exclusive alternatives (sh:xone). The union is not validated for exclusivity at construction: branches may overlap, and the design proves nothing about their distinguishability. Discrimination is instead data-driven against caller-supplied values: a state value (persistence) must single out exactly one variant (sh:xone), rejected when it fits several (ambiguous) or none (unsatisfiable); a model placeholder (retrieval) need only match at least one variant by kind (sh:or), requesting each it fits and rejected only when it fits none. Order is preserved for deterministic error reporting but does not imply priority. Each variant is a ValueShape (a literal, reference, or resource); a localised dictionary is a whole-property type and is not a ValueShape, so a dictionary variant is a compile-time type error. In a retrieval template a union-typed slot is addressed only through the indexed Union form ({"0": ..., "1": ...}); a plain placeholder over it is rejected.

    Important

    Variants are expected to be disjoint: a well-formed union declares branches that no single legal value can satisfy at once, so every admissible value singles out exactly one. Disjointness is a design contract, not checked at construction; overlapping branches are accepted, but a value that fits several is rejected as ambiguous at operation time.

    Cardinality

    The expected cardinality of the polymorphic value set constrains the form of the expected value; for example, given union(string(), reference(PostalAddress)):

    Cardinality Model Type
    scalar string | Reference
    multi-valued readonly (string | Reference)[]

    Inheritance

    When a ResourceShape extends a parent via extends, a union-typed property is merged according to the following rules; see the module overview for the single-variant-narrowing (Form 1) and union-subsetting (Form 2) forms and the full narrowing relation. The child is the extending shape; the parent is the inherited shape.

    Field Override Rule
    kind Cannot be overridden
    model Computed from variants, re-indexed contiguously from 0
    variants Each child variant narrows exactly one parent variant (injective); unpaired parents dropped
    type UnionShape<V extends readonly Lazy<ValueShape>[] = readonly ValueShape[]> = {
        kind: "union";
        model: {
            readonly [K in keyof Variants<V> & `${number}`]: Variants<V>[K]["model"]
        };
        variants: V;
    }

    Type Parameters

    • V extends readonly Lazy<ValueShape>[] = readonly ValueShape[]

      The variants tuple; each variant eager or a Lazy factory for recursive self-reference

    Index

    Properties

    Properties

    kind: "union"

    Discriminator identifying this as a union.

    Inheritance — cannot be overridden.

    model: {
        readonly [K in keyof Variants<V> & `${number}`]: Variants<V>[K]["model"]
    }

    Prototype value for runtime model assembly.

    Variant-keyed record mapping each variant's position to its model type, matching the Union form expected by retrieval templates.

    Inheritance — computed from variants, not user-defined.

    variants: V

    Ordered value shape variants.

    Inheritance — each child variant narrows exactly one parent variant (injective); unpaired parents are dropped (see UnionShape).