jmap-kit
    Preparing search index...

    Represents a JMAP result reference that allows one method call to reference the result of a previous method call within the same request.

    Result references are a core feature of JMAP (RFC 8620 Section 3.7) that enable method calls to depend on the results of earlier method calls in the same request. This allows for efficient batching of interdependent operations without requiring multiple round trips to the server.

    This class is primarily used internally by the JMAP client and invocation system. Users typically create result references through invocation method arguments that accept ResultReferenceInterface objects.

    A result reference consists of:

    • An invocation ID (symbol) that uniquely identifies the method call being referenced
    • A method name to validate the reference type
    • A JSON Pointer path (RFC 6901) to extract a specific value from the result
    // Create a result reference to the "id" property from a previous "Foo/set" call
    const ref = new ResultReference(invocationId, "Foo/set", "/id");

    // The reference can be resolved to a JMAP result reference format
    const jmapRef = ref.resolve(lookupFunction);
    // Returns: { resultOf: "c1", name: "Foo/set", path: "/id" }

    Implements

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Constructs a ResultReference

      Parameters

      • id: symbol

        A unique symbol identifying the invocation being referenced

      • name: string

        The name of the method call being referenced (e.g., "Foo/set")

      • path: string

        A JSON Pointer (RFC 6901) path to the value in the result (e.g., "/id")

      Returns ResultReference

    Accessors

    Methods

    • Resolves this result reference to a JMAP result reference format

      Converts the internal symbol-based invocation ID to a string invocation ID suitable for serialisation in a JMAP request.

      Parameters

      • lookupId: (id: symbol) => Id | undefined

        A function that maps the invocation symbol to its string ID

      Returns JMAPResultReference

      A JMAP result reference object with resultOf, name, and path properties

      If the invocation ID cannot be resolved (invocation not found in request)

      const ref = new ResultReference(invocationId, "Foo/set", "/id");
      const jmapRef = ref.resolve(id => idMap.get(id));
      // Returns: { resultOf: "c1", name: "Foo/set", path: "/id" }