import { AdapterError } from "@chat-adapter/shared"; import type { RelayCredential } from "./credentials.js"; import type { RelayAttachment, RelayAttachmentAllocation, RelayChat, RelayChatLocation, RelayGetMessagesResult, RelayCreatePaymentRequest, RelayLocationRequestResponse, RelayMessage, RelayOutgoingPart, RelayPaymentRequest, RelayPaymentRequestList, RelayPaymentStatus, RelayReactionType, RelaySendMessageResponse } from "./types.js"; export declare const RELAY_DEFAULT_BASE_URL = "https://api.relayapp.im"; export interface RelayClientOptions { /** Relay Agent Token or a resolver evaluated for every Relay API call. */ token?: RelayCredential; baseUrl?: string; fetch?: typeof fetch; } export interface RelayUploadOptions { body: Uint8Array; contentType: string; durationMs?: number; filename: string; height?: number; width?: number; } export declare class RelayApiError extends AdapterError { readonly status: number; readonly relayCode: string; readonly responseBody?: unknown; constructor(status: number, relayCode: string, message: string, responseBody?: unknown); } /** * Map a Relay API status onto the Chat SDK's shared error classes so a * consumer can catch `AdapterRateLimitError` and read `retryAfter`, or catch * `AuthenticationError`, without knowing Relay's HTTP vocabulary. * * `RelayApiError` stays the default: a status Relay defines but the shared * vocabulary has no class for — 409 idempotency conflict, for instance — * must keep its Relay status and code rather than be flattened into a * near-miss. */ export declare function relayHttpError(options: { body: unknown; path: string; status: number; }): AdapterError; /** * Minimal client for only the locked Relay v1 operations used by the adapter. */ export declare class RelayClient { readonly baseUrl: string; private readonly fetchImpl; private readonly token; constructor(options?: RelayClientOptions); private request; sendMessage(options: { chatId: string; idempotencyKey: string; parts: RelayOutgoingPart[]; replyTo?: { messageId: string; partIndex?: number; }; }): Promise; react(options: { customEmoji?: string; messageId: string; operation: "add" | "remove"; partIndex?: number; type: RelayReactionType; }): Promise; /** * Create a payment request on the organization's connected Stripe account. * Send the returned `checkout_url` as a `payment` part. */ createPaymentRequest(body: RelayCreatePaymentRequest, options?: { idempotencyKey?: string; }): Promise; listPaymentRequests(options?: { cursor?: string; limit?: number; status?: RelayPaymentStatus; }): Promise; getPaymentRequest(paymentRequestId: string): Promise; /** Cancel a request that has not been paid; the card changes in place. */ cancelPaymentRequest(paymentRequestId: string): Promise; /** * Ask the person in this one-to-one chat to share their location. The chat * gets a Message from the agent with one `location_request` part; no * position comes back. Wait for `location.sharing.started`, then read it * with `getLocation`. Relay answers 409 while the person already shares, * and in a group chat; 429 after one request in the same chat within 60 s. */ requestLocation(chatId: string): Promise; /** * Read where everyone sharing with the agent in this chat is now: one * GeoJSON Feature per person, coordinates `[longitude, latitude]`. * `data.features` is empty when nobody shares. */ getLocation(chatId: string): Promise; setTyping(chatId: string, active: boolean): Promise; markChatRead(chatId: string): Promise; getChat(chatId: string): Promise; getMessages(options: { chatId: string; cursor?: string; limit?: number; }): Promise; getMessage(messageId: string): Promise; /** * Read Attachment metadata, including a freshly minted `download_url`. * * Relay mints the download link at request time, so this is how an expired * link is replaced. The route authorizes any Chat participant who could read * the Message the Attachment belongs to, not only its owner. */ getAttachment(attachmentId: string): Promise; allocateAttachment(options: Omit & { sizeBytes: number; }): Promise; uploadAttachment(options: RelayUploadOptions): Promise; /** * Download the bytes of an inbound Relay media part. * * A Relay media URL is a sealed download capability: the transfer route is * unauthenticated, so no Agent Token is sent, and the capability expires 60 * minutes after Relay minted it. A download after that window fails with * HTTP 404; `getAttachment` mints a replacement. */ downloadAttachment(options: { attachmentId?: string; url: string; }): Promise; } //# sourceMappingURL=client.d.ts.map