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

    Interface ResourceShape

    Shape definition for linked data resources.

    Validates linked data resources with structural constraints including inheritance, property definitions, and SHACL-aligned validation rules. Resource shapes define the expected structure of linked data resources and support type inference for property values.

    Important

    Resource shapes are closed: validated resources may only contain properties explicitly defined in the shape. Any additional properties will cause validation to fail.

    interface ResourceShape {
        kind: "resource";
        model: Resource;
        validators?: readonly Validator<Resource>[];
        properties: {
            readonly [property: string]:
                | Id
                | Type
                | Property<Range<unknown, number | undefined, number | undefined>>;
        };
        virtual?: boolean;
        name?: Local;
        description?: Local;
        namespace?: Namespace;
        class?: string;
        extends?: Some<Lazy<ResourceShape>>;
        pattern?: string;
        in?: readonly string[];
        hasValue?: readonly string[];
    }

    Hierarchy (View Summary)

    Index

    Properties

    kind: "resource"

    Discriminator identifying this as a resource shape.

    model: Resource

    Prototype value for runtime model assembly.

    Provides a deeply immutable model of the expected TypeScript type for resources matching this shape. When a shape extends parent shapes, inherited properties are merged into the model; local definitions override inherited ones.

    validators?: readonly Validator<Resource>[]

    Custom resource validators.

    SHACL defines custom constraints via SPARQL; this library uses programmatic validators.

    properties: {
        readonly [property: string]:
            | Id
            | Type
            | Property<Range<unknown, number | undefined, number | undefined>>;
    }

    Property shapes defining the expected structure.

    Property keys are either plain identifiers or bindings for computed values. Binding suffixes are stripped when projecting to the resource type via Projection.

    virtual?: boolean

    Marks the resource as dynamically generated.

    When true, indicates the resource is at least partially computed rather than stored.

    undefined (false)

    name?: Local

    Human-readable name for the shape.

    SHACL defines sh:name only for property shapes; extended here to node shapes.

    description?: Local

    Human-readable description of the shape.

    SHACL defines sh:description only for property shapes; extended here to node shapes.

    namespace?: Namespace

    Default namespace for converting property names to IRIs.

    Property names without explicit IRI mappings are resolved relative to this namespace.

    defaultNamespace

    class?: string

    Class constraint for resource instances.

    The absolute IRI identifying the class that resource instances must belong to. If defined, this value is exposed through the property mapped to @type using type.

    Note

    Restricted to a single optional class, unlike SHACL which allows multiple sh:class values.

    extends?: Some<Lazy<ResourceShape>>

    Parent shape(s) this shape inherits from.

    Inherited properties and constraints are merged into the derived shape.

    Warning

    When inheriting from multiple shapes with different namespace values, an overriding namespace must be declared in this shape.

    pattern?: string

    IRI path pattern that resource identifiers must match.

    undefined (no pattern constraint)

    Patterns are IRI-like templates using {name} placeholders for single path segments and /* for trailing wildcards. Patterns may be absolute or root-relative; root-relative patterns match absolute IRIs, ignoring the origin.

    https://example.org/products/{sku}  → https://example.org/products/ABC-456
    https://example.org/categories/* → https://example.org/categories/electronics/phones

    /employees/{id} → https://example.org/employees/123
    /departments/* → https://example.org/departments/sales/emea
    in?: readonly string[]

    Allowed resource identifiers (closed enumeration).

    When specified, resource identifiers must be members of this list. IRIs must be absolute.

    undefined (no enumeration constraint)

    hasValue?: readonly string[]

    Required resource identifiers that must be present.

    When specified, all listed resource identifiers must appear. IRIs must be absolute.

    undefined (no required values)