@grafctory/blue - v0.17.0
    Preparing search index...

    Type Alias ResourceShape<P, M>

    ResourceShape: ResourceConstraints & {
        kind: "resource";
        classes: readonly Reference[];
        parents: P;
        members: M;
    }

    Describes a linked data resource.

    Admits the resources a store holds: a record carrying the members the shape declares, and nothing else, so that what a resource may state is fixed by the shape rather than left to whoever writes it. A shape extends the shapes it lists as parents, carrying their members and constraints on top of its own.

    Inheritance

    Where a shape extends the ones it lists as parents, they are merged according to the following rules. The child is the extending shape; the parent is the inherited one.

    Field Override Rule
    kind Cannot be overridden
    name Always from the child; not inherited
    description Always from the child; not inherited
    space Inherited; conflicting parents without a child override are reported as an error
    class Always from the child; not inherited
    classes Computed from the class of the shapes extended; never stated
    pattern Only a trailing /* admits narrowing; any other case requires equality
    in Child may only drop allowed identifiers
    hasValue Child may only add required identifiers
    members Declared members narrow every parent definition; others take the narrowest one
    validators Union of the checks stated and the ones inherited; every check applies

    A resource the child admits is an instance of every parent. A member stated by several parents therefore takes the definition narrowing all the others, whatever order the parents are listed in, and a member the child declares must narrow the definition of each parent stating it. If no parent definition narrows all the others, an error is reported unless the child redeclares the member to narrow each one, for instance by combining their bounds. Parents disagreeing on hidden, name or description are reconciled by a child stating its own value. A disagreement on any other facet can't be reconciled, as no override may change a facet restricting the values admitted.

    Cross-field validation

    • all merged hasValue entries must be members of the merged in set (if defined)
    • at most one id member and one type member, counted after inheritance
    • no two members may share a forward predicate, nor two a reverse predicate
    • a member stating a reverse predicate must range over resources alone (references, embedded resources, or unions of them)

    Type Parameters

    • P extends Parents = Parents

      The shapes extended, possibly deferred to break definition cycles

    • M extends Members = Members

      The members declared in the shape's own right

    Type Declaration

    • Readonlykind: "resource"

      Discriminator identifying this as a resource shape.

      Inheritance — cannot be overridden.

    • Readonlyclasses: readonly Reference[]

      The classes a resource belongs to beyond the one its shape states.

      Lists the class every extended shape states, transitively and deduplicated, so that a caller may test a resource against a supertype without walking the inheritance chain itself. Each extended shape contributes the class it states, followed by the ones it inherits in turn, in the order the shapes are extended. A shape extending nothing that states a class is empty.

      Together with the class the shape states in its own right, this is the lineage a shape is held to where it stands in for another as a member range.

      Inheritance — computed from the class of the shapes extended; never stated.

    • Readonlyparents: P

      The shapes extended, each possibly deferred to break definition cycles.

      Their members and constraints reach every resource this shape describes, so an extending shape states what it adds or tightens alone.

      Inheritance — states the shapes extended in the shape's own right, and is never itself inherited.

    • Readonlymembers: M

      The members a resource carries.

      Merged as the shape is built: the members declared in the shape's own right override the ones the extended shapes contribute, so a caller reads what a resource carries off the shape rather than by walking the inheritance chain. The shape is closed, so a resource carrying anything else is rejected.

      Inheritance — a declared member narrows the definition of every parent stating it; an undeclared member stated by several parents takes the narrowest definition, whatever order the parents are listed in.