@grafctory/keep
    Preparing search index...

    Function createValidatingStore

    • Creates a validating store backed by a delegate.

      Each method validates its inputs against the supplied shape before forwarding the request to store:

      • entry must be an absolute IRI with no query string and no fragment; otherwise the request is rejected with a RangeError
      • model is validated as a template for lookup, within the bounds of the caller's retrieval scope, and as a collection slice for create, which no retrieval bound applies to as it retrieves nothing
      • state.id, if present, must be nested under entry for create, and equal to entry for update and insert; otherwise the request is rejected with a RangeError
      • state is validated as a resource with captive expansion capped at depth 0, so inline captive batches are rejected; create validates it against the shape of the collected resources, and update and insert against the supplied shape

      The trusted option controls whether lookup responses are re-validated against the shape, as narrowed by the caller's model. It defaults to false, the safe choice for connectors whose source may deliver non-conforming data, such as a remote REST endpoint. Local stores that compute results themselves can pass trusted: true to skip the redundant check.

      The scope option fills in the members a lookup scope leaves out. A deployment that trusts its callers states wide bounds there once, and the wrapped store receives each lookup scope as filled in. The option is a fallback rather than a ceiling, so it never caps the bounds a lookup states for itself.

      Validation failures surface as TraceError or RangeError rejections, in line with the unified Store error channel.

      Parameters

      • store: StoreClient

        Inner StoreClient receiving the validated requests

      • options: { trusted?: boolean; scope?: StoreScope } = {}

        Optional validation options, and the default retrieval scope

        • Optional Readonlytrusted?: boolean

          Whether to skip re-validation of lookup responses against the shape, as narrowed by the caller's model.

          false, treating the wrapped store as untrusted

        • Optional Readonlyscope?: StoreScope

          The retrieval scope that fills in the members a lookup scope leaves out, one by one, before the model of the lookup is checked against its bounds.

          It is a fallback, not a ceiling. A bound the lookup states wins even when it is wider, so a service taking the scope from an untrusted client must cap it before calling the store, as this option never will.

          {}, leaving every lookup within the closed default bounds

      Returns StoreClient

      An immutable StoreClient wrapping store with input validation