import { AbortSignalLike } from '@azure/abort-controller'; import { AccessToken } from '@azure/core-auth'; import { AdditionalPolicyConfig } from '@azure/core-client'; import { AzureLogger } from '@azure/logger'; import { UserAgentPolicyOptions } from '@azure/core-rest-pipeline'; /** * Base class for chat event */ export declare interface BaseChatEvent { /** * Thread Id of the event. */ threadId: string; /** * The Id of the event sender. */ sender: CommunicationIdentifierKind; /** * The display name of the event sender. */ senderDisplayName: string; /** * The Id of the event recipient. */ recipient: CommunicationIdentifierKind; } /** * Event for chat message operations */ export declare interface BaseChatMessageEvent extends BaseChatEvent { /** * The Id of the message. This Id is server generated. */ id: string; /** * The timestamp when the message arrived at the server. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ createdOn: Date; /** * Version of the message. This version is an epoch time in a numeric unsigned Int64 format: * `1593117207131` */ version: string; /** * Type of the chat message. Possible types are "Text" and "RichText/Html". */ type: string; } /** * Event for chat thread operations */ export declare interface BaseChatThreadEvent { /** * Thread Id of the event. */ threadId: string; /** * Version of the thread. This version is an epoch time in a numeric unsigned Int64 format: * `1593117207131` */ version: string; } /** An attachment in a chat message. */ export declare interface ChatAttachment { /** Id of the attachment */ id: string; /** The type of attachment. */ attachmentType: ChatAttachmentType; /** The name of the attachment content. */ name?: string; /** The URL where the attachment can be downloaded */ url?: string; /** The URL where the preview of attachment can be downloaded */ previewUrl?: string; } /** Defines values for AttachmentType. */ export declare type ChatAttachmentType = "image" | "file" | "unknown"; /** * Defines values for chat event. */ export declare type ChatEventId = "chatMessageReceived" | "chatMessageEdited" | "chatMessageDeleted" | "typingIndicatorReceived" | "readReceiptReceived" | "chatThreadCreated" | "chatThreadDeleted" | "chatThreadPropertiesUpdated" | "participantsAdded" | "participantsRemoved"; /** * Event for a deleted chat message. * All chat participants receive this event, including the original sender */ export declare interface ChatMessageDeletedEvent extends BaseChatMessageEvent { /** * The timestamp when the message was deleted. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ deletedOn: Date; } /** * Event for a edited chat message. * All chat participants receive this event, including the original sender */ export declare interface ChatMessageEditedEvent extends ChatMessageReceivedEvent { /** * The timestamp when the message was edited. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ editedOn: Date; } /** * Event for a received chat message. * All chat participants receive this event, including the original sender */ export declare interface ChatMessageReceivedEvent extends BaseChatMessageEvent { /** * Content of the message. */ message: string; /** * Metadata of the message. */ metadata: Record; /** * Chat message attachments. */ attachments?: ChatAttachment[]; } /** * An Azure Communication chat participant. */ export declare interface ChatParticipant { /** * The id of the chat participant. */ id: CommunicationIdentifierKind; /** * Display name for the chat participant. */ displayName: string; /** * Time from which the chat history is shared with the chat participant. * The timestamp is in RFC3339 format: `yyyy-MM-ddTHH:mm:ssZ`. */ shareHistoryTime?: Date; /** * Metadata of the participant. */ metadata: Record; } /** Data retention policy for auto deletion. */ export declare type ChatRetentionPolicy = ThreadCreationDateRetentionPolicy | NoneRetentionPolicy; /** * Event for a created chat thread. * All chat participants receive this event, including the original sender */ export declare interface ChatThreadCreatedEvent extends BaseChatThreadEvent { /** * The timestamp when the thread was created. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ createdOn: Date; /** * The properties of the thread. */ properties: ChatThreadProperties; /** * The list of participants on the thread. */ participants: ChatParticipant[]; /** * Id of the user that created the chat thread. */ createdBy: ChatParticipant; /** * Rentention policy */ retentionPolicy: ChatRetentionPolicy; } /** * Event for an updated chat thread. * All chat participants receive this event, including the original sender */ export declare interface ChatThreadDeletedEvent extends BaseChatThreadEvent { /** * The timestamp when the thread was deleted. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ deletedOn: Date; /** * Id of the user that deleted the chat thread. */ deletedBy: ChatParticipant; /** * Reason of the event. */ reason: string; } /** * Properties of an Azure Communication chat thread. */ export declare interface ChatThreadProperties { /** * Thread topic. */ topic: string; /** * Metadata of the thread. */ metadata: Record; } /** * Event for an updated chat thread. * All chat participants receive this event, including the original sender */ export declare interface ChatThreadPropertiesUpdatedEvent extends BaseChatThreadEvent { /** * The properties of the thread. */ properties: ChatThreadProperties; /** * The timestamp when the thread was updated. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ updatedOn: Date; /** * Id of the user that updated the chat thread. */ updatedBy: ChatParticipant; /** * Rentention policy */ retentionPolicy: ChatRetentionPolicy; } /** * Options for `CommunicationTokenCredential`'s `getToken` function. */ export declare interface CommunicationGetTokenOptions { /** * An implementation of `AbortSignalLike` to cancel the operation. */ abortSignal?: AbortSignalLike; } /** * Identifies a communication participant. */ export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftTeamsAppIdentifier | TeamsExtensionUserIdentifier | UnknownIdentifier; /** * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier. */ export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | TeamsExtensionUserKind | UnknownIdentifierKind; export declare class CommunicationSignalingClient implements SignalingClient { private readonly credential; private readonly logger; private readonly options?; private readonly trouter; private config; private stateChangedListener; private tokenFetchRetries; private resourceEndpoint; private gatewayApiVersion; constructor(credential: CommunicationTokenCredential, logger: AzureLogger, options?: SignalingClientOptions); start(): Promise; stop(isTokenExpired?: boolean): Promise; on(event: "connectionChanged", listener: (state: ConnectionState) => void): void; on(event: "chatMessageReceived", listener: (payload: ChatMessageReceivedEvent) => void): void; on(event: "typingIndicatorReceived", listener: (payload: TypingIndicatorReceivedEvent) => void): void; on(event: "readReceiptReceived", listener: (payload: ReadReceiptReceivedEvent) => void): void; on(event: "chatMessageEdited", listener: (payload: ChatMessageEditedEvent) => void): void; on(event: "chatMessageDeleted", listener: (payload: ChatMessageDeletedEvent) => void): void; on(event: "chatThreadCreated", listener: (payload: ChatThreadCreatedEvent) => void): void; on(event: "chatThreadPropertiesUpdated", listener: (payload: ChatThreadPropertiesUpdatedEvent) => void): void; on(event: "chatThreadDeleted", listener: (payload: ChatThreadDeletedEvent) => void): void; on(event: "participantsAdded", listener: (payload: ParticipantsAddedEvent) => void): void; on(event: "participantsRemoved", listener: (payload: ParticipantsRemovedEvent) => void): void; } /** * The Azure Communication Services token credential. */ export declare interface CommunicationTokenCredential { /** * Gets an `AccessToken` for the user. Throws if already disposed. * @param options - Additional options. */ getToken(options?: CommunicationGetTokenOptions): Promise; } /** * An Azure Communication user. */ export declare interface CommunicationUserIdentifier { /** * Id of the CommunicationUser as returned from the Communication Service. */ communicationUserId: string; } /** * IdentifierKind for a CommunicationUserIdentifier. */ export declare interface CommunicationUserKind extends CommunicationUserIdentifier { /** * The identifier kind. */ kind: "communicationUser"; } export declare enum ConnectionState { Unknown = 0, Connected = 2, Disconnected = 3, Switching = 9 } /** * A Microsoft Teams App. */ export declare interface MicrosoftTeamsAppIdentifier { /** * Optional raw id of the Microsoft Teams App. */ rawId?: string; /** * The unique Microsoft Teams app ID. */ teamsAppId: string; /** * The cloud that the Microsoft Teams App belongs to. If missing, the cloud is "public". */ cloud?: "public" | "dod" | "gcch"; } /** * IdentifierKind for a MicrosoftTeamsAppIdentifier. */ export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier { /** * The identifier kind. */ kind: "microsoftTeamsApp"; } /** * A Microsoft Teams user. */ export declare interface MicrosoftTeamsUserIdentifier { /** * Optional raw id of the Microsoft Teams user. */ rawId?: string; /** * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the Entra ID object id of the user. */ microsoftTeamsUserId: string; /** * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous. */ isAnonymous?: boolean; /** * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is "public". */ cloud?: "public" | "dod" | "gcch"; } /** * IdentifierKind for a MicrosoftTeamsUserIdentifier. */ export declare interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier { /** * The identifier kind. */ kind: "microsoftTeamsUser"; } /** No thread retention policy. */ export declare interface NoneRetentionPolicy { /** Polymorphic discriminator, which specifies the different types this object can be */ kind: "none"; } /** * Event for participants added to a chat thread. * All chat participants receive this event, including the original sender */ export declare interface ParticipantsAddedEvent extends BaseChatThreadEvent { /** * The timestamp when the member was added. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ addedOn: Date; /** * The participants added to the thread. */ participantsAdded: ChatParticipant[]; /** * Id of the user that added the chat participants. */ addedBy: ChatParticipant; } /** * Event for a participant added to a chat thread. * All chat participants receive this event, including the original sender */ export declare interface ParticipantsRemovedEvent extends BaseChatThreadEvent { /** * The timestamp when the member was removed. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ removedOn: Date; /** * The participants removed from the thread. */ participantsRemoved: ChatParticipant[]; /** * Id of the user that removed the chat participants. */ removedBy: ChatParticipant; } /** * A phone number. */ export declare interface PhoneNumberIdentifier { /** * Optional raw id of the phone number. */ rawId?: string; /** * The phone number in E.164 format. */ phoneNumber: string; /** * The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number. */ assertedId?: string; /** * True if the phone number is anonymous. */ isAnonymous?: boolean; } /** * IdentifierKind for a PhoneNumberIdentifier. */ export declare interface PhoneNumberKind extends PhoneNumberIdentifier { /** * The identifier kind. */ kind: "phoneNumber"; } /** * Event for a received read receipt */ export declare interface ReadReceiptReceivedEvent extends BaseChatEvent { /** * The id of the last read chat message. */ chatMessageId: string; /** * The timestamp when the message was read. The timestamp is in RFC3339 format: yyyy-MM-ddTHH:mm:ssZ */ readOn: Date; } export declare interface SignalingClient { /** * Start the realtime connection. */ start(): void; /** * Stop the realtime connection and unsubscribe all event handlers. */ stop(isTokenExpired?: boolean): void; /** * Listen to connectionChanged events. */ on(event: "connectionChanged", listener: (state: ConnectionState) => void): void; /** * Listen to chatMessageReceived events. */ on(event: "chatMessageReceived", listener: (payload: ChatMessageReceivedEvent) => void): void; /** * Listen to typingIndicatorReceived events. */ on(event: "typingIndicatorReceived", listener: (payload: TypingIndicatorReceivedEvent) => void): void; /** * Listen to readReceiptReceived events. */ on(event: "readReceiptReceived", listener: (payload: ReadReceiptReceivedEvent) => void): void; /** * Listen to chatMessageEdited events. */ on(event: "chatMessageEdited", listener: (payload: ChatMessageEditedEvent) => void): void; /** * Listen to chatMessageDeleted events. */ on(event: "chatMessageDeleted", listener: (payload: ChatMessageDeletedEvent) => void): void; /** * Listen to chatThreadCreated events. */ on(event: "chatThreadCreated", listener: (payload: ChatThreadCreatedEvent) => void): void; /** * Listen to chatThreadPropertiesUpdated events. */ on(event: "chatThreadPropertiesUpdated", listener: (payload: ChatThreadPropertiesUpdatedEvent) => void): void; /** * Listen to chatThreadDeleted events. */ on(event: "chatThreadDeleted", listener: (payload: ChatThreadDeletedEvent) => void): void; /** * Listen to participantsAdded events. */ on(event: "participantsAdded", listener: (payload: ParticipantsAddedEvent) => void): void; /** * Listen to participantsRemoved events. */ on(event: "participantsRemoved", listener: (payload: ParticipantsRemovedEvent) => void): void; } export declare interface SignalingClientOptions { registrationTimeInMs?: number; resourceEndpoint?: string; gatewayApiVersion?: string; additionalPolicies?: AdditionalPolicyConfig[]; userAgentOptions?: UserAgentPolicyOptions; } /** * A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up. */ export declare interface TeamsExtensionUserIdentifier { /** * Optional raw id of the Microsoft Teams Extension user. */ rawId?: string; /** * The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user. */ userId: string; /** * The tenant Id of the Microsoft Teams Extension user. */ tenantId: string; /** * The Azure Communication Services resource Id. */ resourceId: string; /** * The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is "public". */ cloud?: "public" | "dod" | "gcch"; } /** * IdentifierKind for a TeamsExtensionUserIdentifier. */ export declare interface TeamsExtensionUserKind extends TeamsExtensionUserIdentifier { /** * The identifier kind. */ kind: "teamsExtensionUser"; } /** Thread retention policy based on thread creation date. */ export declare interface ThreadCreationDateRetentionPolicy { /** Polymorphic discriminator, which specifies the different types this object can be */ kind: "threadCreationDate"; /** Indicates how many days after the thread creation the thread will be deleted. */ deleteThreadAfterDays: number; } /** * Event for a received typing indicator when a chat participant is typing. * All chat participants receive this event, including the original sender */ export declare interface TypingIndicatorReceivedEvent extends BaseChatEvent { /** * Version of the message. */ version: string; /** * The timestamp when the message arrived at the server. The timestamp is in RFC3339 format: * `yyyy-MM-ddTHH:mm:ssZ`. */ receivedOn: Date; } /** * An unknown identifier that doesn't fit any of the other identifier types. */ export declare interface UnknownIdentifier { /** * Id of the UnknownIdentifier. */ id: string; } /** * IdentifierKind for UnknownIdentifier. */ export declare interface UnknownIdentifierKind extends UnknownIdentifier { /** * The identifier kind. */ kind: "unknown"; } export { }