import { Channel } from 'stream-chat'; import { MessageCustomType } from '@linktr.ee/messaging-taxonomy'; import { OfficialCtaActionPayload } from '@linktr.ee/messaging-taxonomy'; import { StreamChat } from 'stream-chat'; /** * Builds an offline Stream client seeded with a single direct conversation, so * consumers can render the **real** messaging UI (MessagingProvider → * MessagingShell → ChannelView) without a Stream backend — for `dev:mock-*` * surfaces and Storybook. It is a real `StreamChat` whose network calls * (`connectUser`, `queryChannels`, `channel.watch`, `channel.sendMessage`) are * replaced with in-memory behaviour driven by Stream's own channel-state * machinery, so rendering fidelity matches production. * * Ships from `@linktr.ee/messaging-react/testing` and must never be imported by * production code. */ export declare function createMockMessagingClient({ currentUser, participant, messages, channelId, onSend, }: CreateMockMessagingClientOptions): MockMessagingClient; export declare interface CreateMockMessagingClientOptions { /** The connected/viewing user. */ currentUser: MockMessagingUser; /** The other party in the direct conversation (e.g. the creator/linker). */ participant: MockMessagingUser; /** Seed conversation, oldest-first. */ messages?: MockMessage[]; /** Channel id; defaults to `mock-dm`. */ channelId?: string; /** * Optional canned reply. Called after the viewer sends a message; return the * reply text (or a partial message) to have `participant` echo a response, or * a falsy value for no reply. Drives the "send echo" in `dev:mock-messaging`. */ onSend?: (text: string) => string | { text?: string; attachments?: unknown[]; } | null | undefined; } export declare interface MessageMetadata { custom_type?: MessageCustomType; listing_id?: string; amount_text?: string; payment_status?: PaymentStatus; attachment_title?: string; attachment_content_type?: 'text' | 'media'; attachment_mime_type?: string; attachment_thumbnail?: string; attachment_detail?: string; /** * The client surface a linker send was composed from, when it needs to be * distinguished server-side. A plain reply carries no `sent_from`; a single * reply composed inside stack-detail channel mode sets `'stack_detail'` so the * backend can leave stack removal confirm-gated (client-owned) instead of * silently removing the conversation from its stack. Composes with * `custom_type` — it identifies the send context, not the message kind. (MES-1266) */ sent_from?: 'stack_detail'; /** * Opaque outbound record id on automation messages. The Stream wire field is * `outbound_id`; resolver APIs name this value `outboundRecordId` explicitly. */ outbound_id?: string; } /** * A seed message, authored from the viewer's perspective. `from: 'me'` is the * connected user (the viewer); `from: 'them'` is the other participant. */ export declare interface MockMessage { id?: string; text?: string; from: 'me' | 'them'; /** Stream attachment payloads, rendered by the toolkit's attachment gate. */ attachments?: any[]; /** e.g. `{ custom_type: 'MESSAGE_WELCOME' }`. */ metadata?: Record; } export declare interface MockMessagingClient { /** Pass to ``. */ client: StreamChat; /** The seeded direct-conversation channel. */ channel: Channel; /** Pass to ``. */ participantFilterId: string; } /** A participant in the mock conversation. */ export declare interface MockMessagingUser { id: string; name?: string; image?: string; } export { OfficialCtaActionPayload } /** * Message metadata for paid messaging and chatbot flows. * Used to identify message types and payment status. */ declare type PaymentStatus = 'pending' | 'paid' | 'failed' | 'refunded'; export { } declare module 'stream-chat' { interface CustomAttachmentData extends LinktreeAttachmentData { /** * Dominant colour of the attachment's image, `#RRGGBB`, resolved by the * sender at stage time and persisted on the attachment so every viewer — * and every later render of the same message — paints an identical chin * without re-extracting. Absent on messages sent before MES-1349. */ accent_color?: string; } interface CustomChannelData extends LinktreeChannelData { /** * Whether DM agent auto-replies are paused for this channel. Writer-only * field not read by other clients, so it stays local rather than in the * shared {@link LinktreeChannelData} contract. */ chatbot_paused?: boolean; } interface CustomMemberData { /** * Whether this member follows the channel's linker account. */ is_follower?: boolean; } interface CustomMessageData extends LinktreeMessageData { /** * Message metadata from backend. * Contains type and payment information. */ metadata?: MessageMetadata; /** * DM Agent-specific system message type. * Used as a fallback when metadata.custom_type is not available. */ dm_agent_system_type?: DmAgentSystemType; } }