This example demonstrates the Invocation object API — creating invocations, inspecting their properties, working with arguments, and using result references.
No server connection is needed. Invocations are plain objects created by factory functions. Building a full JMAP request requires a client, but creating and inspecting individual invocations does not.
Clone the jmap-kit repository, then from the repo root:
yarn tsx examples/invocations/invocations.ts
No .env file is required.
Core.request.echo(), Mailbox.request.get(), Email.request.query()).name, .dataType, .method, .id (symbol), .uri.arguments proxy, .getArgument(), .setArgument(), .deleteArgument(), .hasArgument(), .argumentKeys().createReference("/ids") and inspects the ResultReference object.toJSON() shows the [name, arguments, methodCallId] tupleInvocations are never constructed directly. Each capability exposes factory functions grouped under request and response:
const echo = Core.request.echo({ greeting: "Hello" });
const mailboxGet = Mailbox.request.get({ accountId, ids: ["mbox-1"] });
The .arguments property returns a proxy that delegates to getArgument()/setArgument()/deleteArgument():
echo.arguments.greeting; // reads via getArgument("greeting")
echo.setArgument("key", 42); // writes directly
echo.deleteArgument("key"); // removes an argument
invocation.createReference(path) creates a ResultReference that can be passed as an argument to another invocation. The server resolves it during request processing:
const ref = emailQuery.createReference("/ids");
const emailGet = Email.request.get({ accountId, ids: ref });