import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs"; import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs"; export type { Logger, LogLevel } from "./internal/utils/log.mjs"; import * as Opts from "./internal/request-options.mjs"; import * as Errors from "./core/error.mjs"; import * as Pagination from "./core/pagination.mjs"; import { type CursorNoLimitParams, CursorNoLimitResponse, type CursorSearchParams, CursorSearchResponse } from "./core/pagination.mjs"; import * as Uploads from "./core/uploads.mjs"; import * as API from "./resources/index.mjs"; import * as TopLevelAPI from "./resources/top-level.mjs"; import { FocusParams, FocusResponse, SearchParams, SearchResponse } from "./resources/top-level.mjs"; import { APIPromise } from "./core/api-promise.mjs"; import { AssetDownloadParams, AssetDownloadResponse, AssetServeParams, AssetUploadBase64Params, AssetUploadBase64Response, AssetUploadParams, AssetUploadResponse, Assets } from "./resources/assets.mjs"; import { Info, InfoRetrieveResponse } from "./resources/info.mjs"; import { Label, LabelListResponse, Labels } from "./resources/labels.mjs"; import { MessageDeleteParams, MessageListParams, MessageRetrieveParams, MessageSearchParams, MessageSendParams, MessageSendResponse, MessageUpdateParams, MessageUpdateResponse, Messages } from "./resources/messages.mjs"; import { Account, AccountBridge, AccountListResponse, AccountRetrieveResponse, Accounts } from "./resources/accounts/accounts.mjs"; import { App, RecoveryKeyResetResponse, SetupCompleteResponse, SetupRegistrationRequiredResponse, SetupResponseOutput, SetupStateResponse, Verification, VerificationResponse } from "./resources/app/app.mjs"; import { Bridge, BridgeListResponse, BridgeLogin, BridgeRetrieveResponse, Bridges, CookieField, DisappearingTimerCapability, GroupFieldCapability, GroupTypeCapabilities, LoginFlow, LoginInputField, LoginSession, ProvisioningCapabilities, ResolveIdentifierCapabilities } from "./resources/bridges/bridges.mjs"; import { Chat, ChatArchiveParams, ChatCreateParams, ChatCreateResponse, ChatListParams, ChatListResponse, ChatListResponsesCursorNoLimit, ChatMarkReadParams, ChatMarkUnreadParams, ChatNotifyAnywayParams, ChatRetrieveParams, ChatSearchParams, ChatStartParams, ChatStartResponse, ChatUpdateParams, Chats, ChatsCursorSearch } from "./resources/chats/chats.mjs"; import { type Fetch } from "./internal/builtin-types.mjs"; import { HeadersLike, NullableHeaders } from "./internal/headers.mjs"; import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs"; import { type LogLevel, type Logger } from "./internal/utils/log.mjs"; export interface ClientOptions { /** * Bearer access token obtained via OAuth2 PKCE flow or created in-app. Required for authenticated API operations. */ accessToken?: string | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['BEEPER_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['BEEPER_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; } /** * Base class for Beeper Desktop API clients. */ export declare class BaseBeeperDesktop { #private; accessToken: string; baseURL: string; maxRetries: number; timeout: number; logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch; protected idempotencyHeader?: string; private _options; /** * API Client for interfacing with the Beeper Desktop API. * * @param {string | undefined} [opts.accessToken=process.env['BEEPER_ACCESS_TOKEN'] ?? undefined] * @param {string} [opts.baseURL=process.env['BEEPER_BASE_URL'] ?? http://localhost:23373] - Override the default base URL for the API. * @param {number} [opts.timeout=30 seconds] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, accessToken, ...opts }?: ClientOptions); /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this; /** * Focus Beeper Desktop and optionally open a specific chat, jump to a message, or * pre-fill text and an image. * * @example * ```ts * const response = await client.focus(); * ``` */ focus(body?: TopLevelAPI.FocusParams | null | undefined, options?: RequestOptions): APIPromise; /** * Return matching chats, participant matches in group chats, and the first page of * message results in one call. Use the dedicated chat and message search endpoints * for pagination. * * @example * ```ts * const response = await client.search({ query: 'x' }); * ``` */ search(query: TopLevelAPI.SearchParams, options?: RequestOptions): APIPromise; protected defaultQuery(): Record | undefined; protected validateHeaders({ values, nulls }: NullableHeaders): void; protected authHeaders(opts: FinalRequestOptions, schemes: { bearerAuth?: boolean; }): Promise; protected bearerAuth(opts: FinalRequestOptions): Promise; protected stringifyQuery(query: object | Record): string; private getUserAgent; protected defaultIdempotencyKey(): string; protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError; buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string; /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ protected prepareOptions(options: FinalRequestOptions): Promise; /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ protected prepareRequest(request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions; }): Promise; get(path: string, opts?: PromiseOrValue): APIPromise; post(path: string, opts?: PromiseOrValue): APIPromise; patch(path: string, opts?: PromiseOrValue): APIPromise; put(path: string, opts?: PromiseOrValue): APIPromise; delete(path: string, opts?: PromiseOrValue): APIPromise; private methodRequest; request(options: PromiseOrValue, remainingRetries?: number | null): APIPromise; private makeRequest; getAPIList = Pagination.AbstractPage>(path: string, Page: new (...args: any[]) => PageClass, opts?: PromiseOrValue): Pagination.PagePromise; requestAPIList = Pagination.AbstractPage>(Page: new (...args: ConstructorParameters) => PageClass, options: PromiseOrValue): Pagination.PagePromise; fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise; private shouldRetry; private retryRequest; private calculateDefaultRetryTimeoutMillis; buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: { retryCount?: number; }): Promise<{ req: FinalizedRequestInit; url: string; timeout: number; }>; private buildHeaders; private _makeAbort; private buildBody; static DEFAULT_TIMEOUT: number; } /** * API Client for interfacing with the Beeper Desktop API. */ export declare class BeeperDesktop extends BaseBeeperDesktop { static BeeperDesktop: typeof BeeperDesktop; static BeeperDesktopError: typeof Errors.BeeperDesktopError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; /** * Manage connected chat accounts */ accounts: API.Accounts; /** * Manage available bridges, connect or reconnect chat accounts */ bridges: API.Bridges; /** * Manage chats */ chats: API.Chats; /** * User-created labels that organize chats */ labels: API.Labels; /** * Manage messages in chats */ messages: API.Messages; /** * Manage files for message attachments */ assets: API.Assets; /** * Server discovery and capability metadata. Use /v1/info before authentication setup. */ info: API.Info; /** * Manage Beeper account setup and encrypted messaging setup */ app: API.App; } export declare namespace BeeperDesktop { export type RequestOptions = Opts.RequestOptions; export import CursorSearch = Pagination.CursorSearch; export { type CursorSearchParams as CursorSearchParams, type CursorSearchResponse as CursorSearchResponse }; export import CursorNoLimit = Pagination.CursorNoLimit; export { type CursorNoLimitParams as CursorNoLimitParams, type CursorNoLimitResponse as CursorNoLimitResponse, }; export { type FocusResponse as FocusResponse, type SearchResponse as SearchResponse, type FocusParams as FocusParams, type SearchParams as SearchParams, }; export { Accounts as Accounts, type Account as Account, type AccountBridge as AccountBridge, type AccountRetrieveResponse as AccountRetrieveResponse, type AccountListResponse as AccountListResponse, }; export { Bridges as Bridges, type Bridge as Bridge, type BridgeLogin as BridgeLogin, type CookieField as CookieField, type DisappearingTimerCapability as DisappearingTimerCapability, type GroupFieldCapability as GroupFieldCapability, type GroupTypeCapabilities as GroupTypeCapabilities, type LoginFlow as LoginFlow, type LoginInputField as LoginInputField, type LoginSession as LoginSession, type ProvisioningCapabilities as ProvisioningCapabilities, type ResolveIdentifierCapabilities as ResolveIdentifierCapabilities, type BridgeRetrieveResponse as BridgeRetrieveResponse, type BridgeListResponse as BridgeListResponse, }; export { Chats as Chats, type Chat as Chat, type ChatCreateResponse as ChatCreateResponse, type ChatListResponse as ChatListResponse, type ChatStartResponse as ChatStartResponse, type ChatListResponsesCursorNoLimit as ChatListResponsesCursorNoLimit, type ChatsCursorSearch as ChatsCursorSearch, type ChatCreateParams as ChatCreateParams, type ChatRetrieveParams as ChatRetrieveParams, type ChatUpdateParams as ChatUpdateParams, type ChatListParams as ChatListParams, type ChatArchiveParams as ChatArchiveParams, type ChatMarkReadParams as ChatMarkReadParams, type ChatMarkUnreadParams as ChatMarkUnreadParams, type ChatNotifyAnywayParams as ChatNotifyAnywayParams, type ChatSearchParams as ChatSearchParams, type ChatStartParams as ChatStartParams, }; export { Labels as Labels, type Label as Label, type LabelListResponse as LabelListResponse }; export { Messages as Messages, type MessageUpdateResponse as MessageUpdateResponse, type MessageSendResponse as MessageSendResponse, type MessageRetrieveParams as MessageRetrieveParams, type MessageUpdateParams as MessageUpdateParams, type MessageListParams as MessageListParams, type MessageDeleteParams as MessageDeleteParams, type MessageSearchParams as MessageSearchParams, type MessageSendParams as MessageSendParams, }; export { Assets as Assets, type AssetDownloadResponse as AssetDownloadResponse, type AssetUploadResponse as AssetUploadResponse, type AssetUploadBase64Response as AssetUploadBase64Response, type AssetDownloadParams as AssetDownloadParams, type AssetServeParams as AssetServeParams, type AssetUploadParams as AssetUploadParams, type AssetUploadBase64Params as AssetUploadBase64Params, }; export { Info as Info, type InfoRetrieveResponse as InfoRetrieveResponse }; export { App as App, type RecoveryKeyResetResponse as RecoveryKeyResetResponse, type SetupCompleteResponse as SetupCompleteResponse, type SetupRegistrationRequiredResponse as SetupRegistrationRequiredResponse, type SetupResponseOutput as SetupResponseOutput, type SetupStateResponse as SetupStateResponse, type Verification as Verification, type VerificationResponse as VerificationResponse, }; export type APIError = API.APIError; export type AppStateSnapshot = API.AppStateSnapshot; export type Attachment = API.Attachment; export type AttachmentCapabilities = API.AttachmentCapabilities; export type ChatCapabilities = API.ChatCapabilities; export type ChatDraft = API.ChatDraft; export type ChatStateCapabilities = API.ChatStateCapabilities; export type DraftAttachment = API.DraftAttachment; export type Error = API.Error; export type LinkPreview = API.LinkPreview; export type Message = API.Message; export type Reaction = API.Reaction; export type SendStatus = API.SendStatus; export type User = API.User; } //# sourceMappingURL=client.d.mts.map