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

    Module value

    Value shape types and operations.

    Defines the Shape any value is validated against, derives TypeScript types from shapes, and provides the accessors for navigating them. Callers holding a shape don't need to know which kind of shape it is, and since value types are derived from the shapes describing them, the two can't drift apart.

    Shape kinds

    Each kind of shape is defined in its own module:

    Shape hierarchy

    sh is the namespace of the SHACL terms shapes are modelled on.

    Cardinality

    A Range pairs a shape with the number of values allowed, and describes both the values of a declared member and the values a path resolves to. A range isn't a shape: the shape describes each value, the range how many there may be.

    Value types

    State is the type of a value described by a shape, and Draft the type of a resource or collection item to be persisted, with its identifier optional:

    type Item = State<typeof Product>;                           // { readonly id: Reference, readonly name: string, … }
    type Seed = Draft<typeof Product>; // { readonly name: string, …, readonly id?: Reference }

    blueprint resolves the shape a draft posted to a collection property must satisfy, so that a new item can be validated before it is stored.

    Retrieval types

    Model and Slice are the models allowed for retrieving a resource or a collection it holds, so that a model naming members the shape doesn't declare fails to compile. Match and Items are the types of a retrieved resource and of the items of a retrieved collection, restricted to the members the model asks for, so callers get back exactly what they asked for:

    type Read = Match<typeof Product, { name: {} }>;             // { readonly name: string }
    type Rows = Items<typeof Catalog, { items: { name: {} } }>; // readonly { readonly name: string }[]

    items gets the items of the collection from a resource retrieved with a slice, typed as Items.

    Navigation

    eager resolves a shape or range deferred to break definition cycles, returning resource shapes with their inherited members merged in; repeated calls return the same value.

    collection resolves the collection property a slice names, whether the shape declares or inherits it.

    effective resolves the Range reached by a path and transform pipe, so that callers can type a projection column or a constraint operand without walking the shape themselves. Links are followed only when the path continues past them, and each branch of a union is explored in turn. Paths naming a member no branch declares, and pipes that can't apply to the values reached, are reported as issues.

    Variables

    sh

    SHACL vocabulary namespace.

    Type Aliases

    Shape

    Value shape.

    Range

    Cardinality-constrained value set.

    State

    Resolves the value type of a shape.

    Draft

    Resolves the state of a resource to be persisted.

    Model

    Resolves the models for retrieving a resource.

    Match

    Resolves the type of the resource retrieved by a model.

    Slice

    Resolves the models for retrieving a resource restricted to a single collection.

    Items

    Resolves the type of the items retrieved from a collection.

    Frame

    Resolves the type of a single item retrieved from a collection.

    Functions

    eager

    Resolves a possibly deferred shape or range.

    effective

    Resolves the values a probe reaches.

    collection

    Resolves the collection property a slice names.

    blueprint

    Resolves the shape of the drafts posted to a collection property.

    items

    Resolves the items of a collection property from a retrieved resource.