Default application namespace for property IRI resolution (app:/#).
Shape definition for linked data resources.
Constraints for resource shape factories.
Shape definition for the resource identifier property.
Shape definition for the resource type property.
Shape definition for a resource property.
Constraints for property shape factories.
A ResourceShape entry.
Member definitions for a ResourceShape factory.
Member definition accepted by the resource factory.
Assembles the per-key template prototype backing a resource's model.
Narrows locally-declared entries against an inherited template, flagging incompatible overrides.
Expands an inherited slot type into the union of its valid narrowings.
Resolves the inherited template contributed by a resource's extends clause.
Composes the resource model from local entries and inherited template.
Projects a Member to its state-side runtime value type.
Relaxes the keys of an object type into optional keys wherever the value type admits absence.
Strips index signatures from a record type, keeping only explicitly declared entries.
Collapses a union type into the intersection of its members.
Collapses an intersection of object types into a single object type.
Resolves a shape's own class.
Resolves a shape's inherited classes.
Resolves a shape's identifier field name.
Resolves a shape's type field name.
Resolves a shape's entries.
Creates resource shapes.
Creates a marker for the resource identifier property.
Creates a marker for the resource type property.
Creates property shapes.
Resource shapes and factories.
Defines ResourceShape and the resource, property, id, and type factories used to declare the expected structure of linked data resources. Shapes carry property definitions, cardinality constraints, IRI mappings, and inheritance, and drive both runtime validation and compile-time type inference through Content. Use model to extract the deeply typed retrieval template stored on a resource shape.
Resource shapes are closed: validated resources may only contain entries explicitly defined in the shape. Any additional entries will cause validation to fail.
All IRI values in validated resources must be absolute. When decoding client input, relative references may be auto-resolved using the
baseoption in decodeResource or decodeSelection.Defining Resource Shapes
Combine property definitions with value ranges to define resource structures:
Properties and Ranges
Ranges define cardinality constraints for property values:
Naked ranges are automatically wrapped in a property; use the explicit property factory when IRI mappings or labels are needed:
Resource References and Embedding
Resource entries link to other resources in two ways. A reference wrapper links to a standalone resource, an independently identified and managed entity. A direct shape inclusion defines an embedded resource, a nested object with no independent identity, created and managed together with its parent.
An embedded resource shape may not carry an id entry: embedded resources have no independent identity, so a nested resource state bearing an identifier is rejected during state validation rather than at shape construction, since an id-bearing embedded range is indistinguishable from an expanded captive reference until a state is checked against it. A type entry is accepted and validated in both state and template retrieval.
Self-referential shapes use lazy factories to defer resolution and avoid infinite recursion at definition time:
Retrieval Form
In a retrieval template, an embedded resource property accepts only a nested resource template, a nested object validated against this shape and subject to the template validator's
depthbudget. Bare IRI strings are not accepted, since an embedded resource has no independent identifier of its own. See validate for the full form comparison and reference!ReferenceShape for the companion standalone form.Property Mappings versus Foreign References
The forward and reverse mappings on a property control how property values are persisted — both write actual property mappings. The foreign flag on a reference shape is an independent concept: a read-only view over mappings owned by another property that does not write any mappings on insert. During resource validation, foreign reference entries are rejected; during template validation they are accepted for data retrieval.
Embedded versus Captive Resources
Embedded resources have no independent identity or lifecycle and are always managed as part of their parent. An embedded resource shape may not carry an id entry: the rejection is enforced during state validation rather than at shape construction, since an id-bearing embedded range is indistinguishable from an expanded captive reference until a resource state is checked against it. A type entry is accepted and validated in both state and template retrieval. Embedded resources are defined by directly including a resource shape without a reference wrapper.
Captive resources, identified by the captive flag, have independent identity and lifecycle but cannot outlive the source resource and are automatically cascade-removed when it is deleted.
Inheritance
Extend parent shapes to inherit entries and constraints:
Constraints are enforced conjunctively: when a child shape overrides an inherited property, values must satisfy both the child's constraints and all inherited constraints. Overrides can restrict inherited constraints but never relax them.
Constraints that can be expressed in the type system — such as non-empty set requirements on
in,hasValue,languageIn, andvalidators— are enforced at compile time and not re-validated at runtime.Narrowing union slots
When a parent declares a union-typed slot, an extending shape may drop variants and tighten the variants it keeps, but never add new ones. Narrowing takes one of two forms:
kind, only-tightening constraints, a matchingdatatypeforstring/number, and a matching target shape forreferenceor a subtypeclassforresource). The merged slot becomes a bare value shape; consumers see the variant's plain model rather than the union's variant-keyed model.The merged union's
modelre-indexes contiguously from0; consumers must key off the shape's ownmodel, not assume positional alignment with an ancestor. See UnionShape for the full inheritance contract.Polymorphic Properties
Use union for entries accepting multiple value types. Variants are supplied as positional arguments and act as mutually exclusive alternatives (
sh:xone): astatevalue singles out exactly one variant (sh:xone) on write, while amodelplaceholder matches at least one by kind (sh:or) on read. Cardinality constraints belong on the enclosing SetShape, not on individual variants. At runtime, values are stored directly with no variant wrapping:Either variant is accepted at the same property position:
Custom Validators
Implement custom resource-level constraints as validators reporting keyed Trace records, or
undefinedwhen the resource passes:See