@metreeca/keep
    Preparing search index...

    Interface StoreClient

    Model-driven resource CRUD operations.

    Persists and retrieves linked data resources as shape-validated states and query projections. This is the data surface a connector implements against its backend, and the client a execute task works through.

    interface StoreClient {
        lookup<S extends Lazy<ResourceShape>, T extends Model<S, T>>(
            request: StoreLookup<S, T>,
            scope?: StoreScope,
        ): Promise<Optional<Match<S, T>>>;
        create<
            S extends Lazy<ResourceShape>,
            T extends
            
                    | Model<S, T>
                    | Template & Entries<S, T>
                    | Template & Entries<S, T> & {
                        readonly [F in string | number | symbol]: F extends Repeated<S>
                            ? Collecting<S, F, T[F]>
                            : never
                    },
        >(
            request: StoreCreate<S, T>,
        ): Promise<Optional<string>>;
        update<S extends Lazy<ResourceShape>>(
            request: StoreUpdate<S>,
        ): Promise<Optional<string>>;
        delete<S extends Lazy<ResourceShape>>(
            request: StoreDelete<S>,
        ): Promise<Optional<string>>;
        insert<S extends Lazy<ResourceShape>>(
            request: StoreUpdate<S>,
        ): Promise<string>;
        remove<S extends Lazy<ResourceShape>>(
            request: StoreDelete<S>,
        ): Promise<string>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Look up a resource.

      Retrieves the resource identified by entry. The result holds only the members named by the model Template, and expands the linked resources the template reaches. Values are typed after the shape: the template states which members are wanted, not what they are.

      Multi-valued members are retrieved as collections. Filtering, ordering and pagination constraints are stated under the member name, next to its retrieval keys. A Projection stated there in place of a template returns rows of computed values, keyed by the names of its bindings. A collection with no matching item is omitted from the result, like any other member without a value.

      Note

      shape and model are kept distinct so that a single shape can serve many retrieval templates. For example, a server may wire one shape at startup and accept any admissible model decoded from each client request. A template retrieving every member the shape declares MUST be written out explicitly.

      Caution

      By default, model templates support the full query language, including aggregate transforms and nested expansion. When exposing retrieval to untrusted clients, restrict query complexity through the scope: set plain to true, depth to 0 or a positive value, and/or limit to a maximum result set size.

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the retrieval

      • T extends Model<S, T>

        The retrieval template, naming only members the shape carries

      Parameters

      • request: StoreLookup<S, T>

        The resource to retrieve, the shape describing it and the template narrowing it

      • Optionalscope: StoreScope

        The retrieval scope, bounding model and setting the locale priority

      Returns Promise<Optional<Match<S, T>>>

      A promise resolving to an immutable copy of the resource data narrowed to the members model names, or to undefined if the resource is not present in the store; rejects with a RangeError if entry is not an absolute IRI, a TraceError if model doesn't validate against the shape, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

    • Create a resource.

      Adds a new resource to a collection held by the resource identified by entry. The collecting property is the single multi-valued property named by model, and the new resource is stored as described by the shape that property ranges over. Nothing is created if a resource already exists under the identifier of the new one.

      The new resource is identified by the id of its state, which must be nested under entry. If id is left out, the store mints one under entry, following the identifier pattern declared by the collected shape, if any. Each {name} slot is filled with the like-named member of state, which must be a single path segment. Any other slot is filled with an opaque segment. A remote store may leave the choice of identifier to the service holding the collection.

      Specific reference kinds are handled as follows:

      • embedded references — cascades recursively with the same semantics
      • captive references — accepted only as bare IRI references; inline captive batches are rejected, as state is always validated at depth 0
      • foreign references — skipped, as their data is owned by the defining resource

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the creation, describing the collecting resource

      • T extends
            | Model<S, T>
            | Template & Entries<S, T>
            | Template & Entries<S, T> & {
                readonly [F in string | number | symbol]: F extends Repeated<S>
                    ? Collecting<S, F, T[F]>
                    : never
            }

        The collection slice, naming the collecting property

      Parameters

      • request: StoreCreate<S, T>

        The resource collecting the new one, the shape describing it, the slice naming the collecting property and the initial state of the new resource

      Returns Promise<Optional<string>>

      A promise resolving to the Reference identifying the created resource, or to undefined if a resource already exists under that identifier; rejects with a RangeError if entry is not an absolute IRI, if state carries an id not nested under entry or if a member filling an identifier slot is not a single path segment, a TraceError if model or state doesn't validate against the shape, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

      insert for unconditional insertion under a known identifier

    • Update a resource.

      Replaces the resource's own data if the resource already exists, fully removing any previously existing embedded data. Specific reference kinds are handled as follows:

      • embedded references — cascades recursively with the same semantics
      • captive references — accepted only as bare IRI references; inline captive batches are rejected, as state is always validated at depth 0
      • foreign references — skipped, as their data is owned by the defining resource

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the update, describing the state

      Parameters

      • request: StoreUpdate<S>

        The resource to update, the shape validating it and its replacement state

      Returns Promise<Optional<string>>

      A promise resolving to the entry Reference of the updated resource, or to undefined if the resource doesn't exist; rejects with a RangeError if entry is not an absolute IRI or if state carries an id differing from entry, a TraceError if state doesn't validate against the shape, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

      insert for unconditional insertion

    • Delete a resource.

      Removes the resource's own data and clears references to it from other resources, if the resource exists. Specific reference kinds are handled as follows:

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the deletion, identifying the data cascaded with the resource

      Parameters

      • request: StoreDelete<S>

        The resource to delete and the shape identifying the data cascade-deleted with it

      Returns Promise<Optional<string>>

      A promise resolving to the entry Reference of the deleted resource, or to undefined if the resource doesn't exist; rejects with a RangeError if entry is not an absolute IRI, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

      remove for unconditional removal

    • Insert a resource.

      Unconditionally inserts or replaces the resource's own data, fully removing any previously existing embedded data. Specific reference kinds are handled as follows:

      • embedded references — cascades recursively with the same semantics
      • captive references — accepted only as bare IRI references; inline captive batches are rejected, as state is always validated at depth 0
      • foreign references — skipped, as their data is owned by the defining resource

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the insertion, describing the state

      Parameters

      • request: StoreUpdate<S>

        The resource to insert, the shape validating it and its state

      Returns Promise<string>

      A promise resolving to the entry Reference of the inserted resource; rejects with a RangeError if entry is not an absolute IRI or if state carries an id differing from entry, a TraceError if state doesn't validate against the shape, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

      • create for conditional creation
      • update for conditional replacement
    • Remove a resource.

      Unconditionally removes the resource's own data and clears references to it from other resources. Specific reference kinds are handled as follows:

      Type Parameters

      • S extends Lazy<ResourceShape>

        The shape driving the removal, identifying the data cascaded with the resource

      Parameters

      • request: StoreDelete<S>

        The resource to remove and the shape identifying the data cascade-removed with it

      Returns Promise<string>

      A promise resolving to the entry Reference of the removed resource; rejects with a RangeError if entry is not an absolute IRI, or a Problem on network, storage, or other processing errors

      Error if the store has been closed

      delete for conditional removal