/** * Stream Chat custom data type augmentation. * * This file extends Stream Chat's type system by augmenting their empty * CustomMessageData and CustomChannelData interfaces with our custom properties. * * @see https://getstream.io/chat/docs/sdk/react/guides/typescript_and_custom_data_types/ * * Note: We use a .ts extension instead of .d.ts so that this file can be * imported as a module and included in the build. Declaration files (.d.ts) * are ambient and cannot be imported - they require manual build configuration * to be included in the distributed types. */ import { type ClassifiableMessage, type MessageCustomType, type DmAgentSystemType, type AgeSafetySystemType, type EscalationSystemType, type LinktreeChannelData, type LinktreeMessageData, type LinktreeAttachmentData, type OfficialCtaActionKind, type OfficialCtaActionPayload, } from '@linktr.ee/messaging-taxonomy' import type { Attachment, LocalMessage } from 'stream-chat' import 'stream-chat' /** * System `custom_type` sub-unions consumed by {@link CustomSystemMessage}, * re-exported from the shared taxonomy so this module stays their single local * entry point. */ export type { DmAgentSystemType, AgeSafetySystemType, EscalationSystemType } /** * Official CTA action vocabulary, re-exported from the shared taxonomy so web * consumers keep importing it from this package while the single source of * truth lives in `@linktr.ee/messaging-taxonomy`. */ export type { OfficialCtaActionKind, OfficialCtaActionPayload } /** * Message metadata for paid messaging and chatbot flows. * Used to identify message types and payment status. */ export type PaymentStatus = 'pending' | 'paid' | 'failed' | 'refunded' export 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 } /** * Structured attachment shape for server-authored Linktree official CTA cards. * The `action` payload type is owned by the taxonomy; the `Attachment &` shape * stays here because this package is the SDK-aware (stream-chat) layer. */ export type OfficialCtaAttachment = Attachment & { action?: OfficialCtaActionPayload type: 'linktree_official_cta' } 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 } } /** * Build-only guarantee that stream-chat's augmented `LocalMessage` stays * structurally assignable to the taxonomy's {@link ClassifiableMessage}, so the * shared classification predicates accept a message from this package unchanged. * If a future augmentation narrows `metadata`/`custom_type` incompatibly, this * fails to compile. Type-only — emits no runtime code. */ type Expect = T type _AssertLocalMessageIsClassifiable = Expect< LocalMessage extends ClassifiableMessage ? true : false >