jmap-kit
    Preparing search index...

    Interface JMAPClientInterface<T>

    Comprehensive interface for JMAP client functionality. This interface defines all the methods and properties that a JMAP client should provide.

    interface JMAPClientInterface<T> {
        accounts: Readonly<Record<Id, JMAPAccount>> | null;
        apiUrl: string | null;
        capabilityRegistry: CapabilityRegistryInterface;
        connectionStatus: ConnectionStatus;
        downloadUrl: string | null;
        eventSourceUrl: string | null;
        primaryAccounts: Readonly<Partial<Record<JMAPCapability, Id>>>;
        serverCapabilities: Readonly<JMAPServerCapabilities> | null;
        uploadUrl: string | null;
        username: string | null;
        connect(signal?: AbortSignal): Promise<void>;
        createRequestBuilder(): T;
        disconnect(): Promise<void>;
        downloadFile(
            accountId: Id,
            blobId: Id,
            name: string,
            type: string,
            signal?: AbortSignal,
        ): Promise<Blob>;
        registerCapabilities(
            ...capabilities: CapabilityDefinition[],
        ): Promise<CapabilityRegistrationResult>;
        sendAPIRequest(
            jmapRequest: T,
            signal?: AbortSignal,
        ): Promise<
            {
                createdIds: IdMap;
                methodResponses: InvocationList<BaseInvocationArgs>;
                sessionState: string;
            },
        >;
        uploadFile(
            accountId: Id,
            file: Blob | ArrayBuffer | File,
            signal?: AbortSignal,
        ): Promise<JMAPUploadResponse>;
        withEmitter(emitter: EventEmitterFn): this;
        withHeaders(headers: Headers | Record<string, string>): this;
        withHostname(hostname: string): this;
        withLogger(logger: Logger): this;
        withPort(port: number): this;
    }

    Type Parameters

    • T

    Implemented by

    Index

    Properties

    accounts: Readonly<Record<Id, JMAPAccount>> | null

    The accounts from the session object, or null if not connected

    apiUrl: string | null

    The API URL for JMAP API requests

    capabilityRegistry: CapabilityRegistryInterface

    Get the capability registry for the client

    connectionStatus: ConnectionStatus

    The current connection status of the client

    downloadUrl: string | null

    The download URL template

    eventSourceUrl: string | null

    The event source URL template

    primaryAccounts: Readonly<Partial<Record<JMAPCapability, Id>>>

    The primary accounts from the session object

    serverCapabilities: Readonly<JMAPServerCapabilities> | null

    The server capabilities from the session object, or null if not connected

    uploadUrl: string | null

    The upload URL template

    username: string | null

    The username from the session object

    Methods

    • Connect to the JMAP server

      Parameters

      • Optionalsignal: AbortSignal

      Returns Promise<void>

    • Download a file from the JMAP server

      Parameters

      • accountId: Id
      • blobId: Id
      • name: string
      • type: string
      • Optionalsignal: AbortSignal

      Returns Promise<Blob>

    • Send an API request to the JMAP server

      Parameters

      • jmapRequest: T
      • Optionalsignal: AbortSignal

      Returns Promise<
          {
              createdIds: IdMap;
              methodResponses: InvocationList<BaseInvocationArgs>;
              sessionState: string;
          },
      >

    • Set additional headers for requests

      Parameters

      • headers: Headers | Record<string, string>

      Returns this

    • Set the hostname for the JMAP server

      Parameters

      • hostname: string

      Returns this