Stone.js API
    Preparing search index...

    Interface ResourceContext<EventType, PrincipalType>

    The context a projection is given.

    Open on purpose: a resource reads whatever it needs, and the middleware fills in what the request carried. The authenticated principal is part of it, because deciding what a caller may see is the most common reason a projection differs between two callers.

    interface ResourceContext<EventType = unknown, PrincipalType = unknown> {
        event?: EventType;
        fields?: string[];
        fragment?: string;
        include?: string[];
        principal?: PrincipalType;
        [key: string]: unknown;
    }

    Type Parameters

    • EventType = unknown
    • PrincipalType = unknown

    Indexable

    • [key: string]: unknown

      Anything else a resource needs.

    Index
    event?: EventType

    The event being answered, for a resource that needs more than the parameters above.

    Typed by the resource for the same reason, and unknown by default because the module is agnostic of the platform the event came from.

    fields?: string[]

    Requested sparse fieldset: narrows the output to these top-level keys.

    fragment?: string

    The requested fragment, when the caller asked for one by name.

    include?: string[]

    Requested relations to embed.

    principal?: PrincipalType

    The authenticated principal, when the application has one.

    Typed by the resource, because deciding what a caller may see is the most common reason two callers get different shapes, and unknown makes every such decision a cast. The default stays unknown: this module never assumes an application has users, let alone what a user is.