import 'core-js/features/promise'; import 'url-search-params-polyfill'; import { AjaxCreationMethod } from 'rxjs/observable/dom/AjaxObservable'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { Observable } from 'rxjs/Observable'; import { IScheduler } from 'rxjs/Scheduler'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/combineLatest'; import 'rxjs/add/operator/count'; import 'rxjs/add/operator/delay'; import 'rxjs/add/operator/do'; import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/mergeMap'; import 'rxjs/add/operator/concatMap'; import 'rxjs/add/operator/retryWhen'; import 'rxjs/add/operator/share'; import 'rxjs/add/operator/take'; import 'rxjs/add/observable/dom/ajax'; import 'rxjs/add/observable/empty'; import 'rxjs/add/observable/from'; import 'rxjs/add/observable/interval'; import 'rxjs/add/observable/of'; import 'rxjs/add/observable/throw'; import { DirectLineStreaming } from './directLineStreaming'; export { DirectLineStreaming }; export interface Conversation { conversationId: string; token: string; eTag?: string; streamUrl?: string; referenceGrammarId?: string; } export type MediaType = "image/png" | "image/jpg" | "image/jpeg" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/mp4" | "video/mp4"; export interface Media { contentType: MediaType; contentUrl: string; name?: string; thumbnailUrl?: string; } export interface UnknownMedia { contentType: string; contentUrl: string; name?: string; thumbnailUrl?: string; } export type CardActionTypes = "call" | "downloadFile" | "imBack" | "messageBack" | "openUrl" | "playAudio" | "playVideo" | "postBack" | "signin" | "showImage"; export type CardAction = CallCardAction | DownloadFileCardAction | IMBackCardAction | MessageBackCardAction | OpenURLCardAction | PlayAudioCardAction | PlayVideoCardAction | PostBackCardAction | SignInCardAction | ShowImageCardAction; export interface CallCardAction { image?: string; title: string; type: "call"; value: any; } export interface DownloadFileCardAction { image?: string; title: string; type: "downloadFile"; value: any; } export interface IMBackCardAction { image?: string; title?: string; type: "imBack"; value: string; } export type MessageBackCardAction = MessageBackWithImage | MessageBackWithTitle; export interface MessageBackWithImage { displayText?: string; image: string; text?: string; title?: string; type: "messageBack"; value?: any; } export interface MessageBackWithTitle { displayText?: string; image?: string; text?: string; title: string; type: "messageBack"; value?: any; } export interface OpenURLCardAction { image?: string; title: string; type: "openUrl"; value: any; } export interface PlayAudioCardAction { image?: string; title: string; type: "playAudio"; value: any; } export interface PlayVideoCardAction { image?: string; title: string; type: "playVideo"; value: any; } export interface PostBackCardAction { image?: string; title?: string; type: "postBack"; value: any; } export interface ShowImageCardAction { image?: string; title: string; type: "showImage"; value: any; } export interface SignInCardAction { image?: string; title: string; type: "signin"; value: any; } export interface CardImage { alt?: string; url: string; tap?: CardAction; } export interface HeroCard { contentType: "application/vnd.microsoft.card.hero"; content: { title?: string; subtitle?: string; text?: string; images?: CardImage[]; buttons?: CardAction[]; tap?: CardAction; }; } export interface Thumbnail { contentType: "application/vnd.microsoft.card.thumbnail"; content: { title?: string; subtitle?: string; text?: string; images?: CardImage[]; buttons?: CardAction[]; tap?: CardAction; }; } export interface Signin { contentType: "application/vnd.microsoft.card.signin"; content: { text?: string; buttons?: CardAction[]; }; } export interface OAuth { contentType: "application/vnd.microsoft.card.oauth"; content: { text?: string; connectionname: string; buttons?: CardAction[]; }; } export interface ReceiptItem { title?: string; subtitle?: string; text?: string; image?: CardImage; price?: string; quantity?: string; tap?: CardAction; } export interface Receipt { contentType: "application/vnd.microsoft.card.receipt"; content: { title?: string; facts?: { key: string; value: string; }[]; items?: ReceiptItem[]; tap?: CardAction; tax?: string; vat?: string; total?: string; buttons?: CardAction[]; }; } export interface FlexCard { contentType: "application/vnd.microsoft.card.flex"; content: { title?: string; subtitle?: string; text?: string; images?: CardImage[]; buttons?: CardAction[]; aspect?: string; }; } export interface AudioCard { contentType: "application/vnd.microsoft.card.audio"; content: { title?: string; subtitle?: string; text?: string; media?: { url: string; profile?: string; }[]; buttons?: CardAction[]; autoloop?: boolean; autostart?: boolean; }; } export interface VideoCard { contentType: "application/vnd.microsoft.card.video"; content: { title?: string; subtitle?: string; text?: string; media?: { url: string; profile?: string; }[]; buttons?: CardAction[]; image?: { url: string; alt?: string; }; autoloop?: boolean; autostart?: boolean; }; } export interface AdaptiveCard { contentType: "application/vnd.microsoft.card.adaptive"; content: any; } export interface AnimationCard { contentType: "application/vnd.microsoft.card.animation"; content: { title?: string; subtitle?: string; text?: string; media?: { url: string; profile?: string; }[]; buttons?: CardAction[]; image?: { url: string; alt?: string; }; autoloop?: boolean; autostart?: boolean; }; } export type KnownMedia = Media | HeroCard | Thumbnail | Signin | OAuth | Receipt | AudioCard | VideoCard | AnimationCard | FlexCard | AdaptiveCard; export type Attachment = KnownMedia | UnknownMedia; export type UserRole = "bot" | "channel" | "user"; export interface User { id: string; name?: string; iconUrl?: string; role?: UserRole; } export type DeliveryMode = "normal" | "stream"; export interface IActivity { type: string; channelData?: any; channelId?: string; conversation?: { id: string; }; eTag?: string; from: User; id?: string; timestamp?: string; deliveryMode?: DeliveryMode; } export type AttachmentLayout = "list" | "carousel"; export interface Message extends IActivity { type: "message"; text?: string; locale?: string; textFormat?: "plain" | "markdown" | "xml"; attachmentLayout?: AttachmentLayout; attachments?: Attachment[]; entities?: any[]; suggestedActions?: { actions: CardAction[]; to?: string[]; }; speak?: string; inputHint?: string; value?: object; } export interface Typing extends IActivity { type: "typing"; } export interface EventActivity extends IActivity { type: "event"; name: string; value: any; } export type Activity = Message | Typing | EventActivity; export interface ActivityGroup { activities: Activity[]; watermark: string; } export declare enum ConnectionStatus { Uninitialized = 0, Connecting = 1, Online = 2, ExpiredToken = 3, FailedToConnect = 4, Ended = 5 } export interface DirectLineOptions { secret?: string; token?: string; conversationId?: string; watermark?: string; domain?: string; webSocket?: boolean; pollingInterval?: number; streamUrl?: string; timeout?: number; botAgent?: string; conversationStartProperties?: any; /** * Per-conversation switch for streaming delivery mode. * If true, every outgoing activity will include deliveryMode: 'stream'. * If false/omitted, deliveryMode is not sent (defaults to 'normal' in ABS). */ streaming?: boolean; } export interface Services { scheduler: IScheduler; WebSocket: typeof WebSocket; ajax: AjaxCreationMethod; random: () => number; } export interface IBotConnection { connectionStatus$: BehaviorSubject; activity$: Observable; end(): void; referenceGrammarId?: string; postActivity(activity: Activity): Observable; getSessionId?: () => Observable; } export declare class DirectLine implements IBotConnection { connectionStatus$: BehaviorSubject; activity$: Observable; private domain; private webSocket; private conversationId; private expiredTokenExhaustion; private secret; private token; private watermark; private streamUrl; private _botAgent; private services; private _userAgent; referenceGrammarId: string; private timeout; private retries; private localeOnStartConversation; private userIdOnStartConversation; private pollingInterval; private tokenRefreshSubscription; private streaming; constructor(options: DirectLineOptions & Partial); private checkConnection; setConnectionStatusFallback(connectionStatusFrom: ConnectionStatus, connectionStatusTo: ConnectionStatus, maxAttempts?: number): (status: ConnectionStatus) => ConnectionStatus; private expiredToken; private startConversation; private refreshTokenLoop; private refreshToken; reconnect(conversation: Conversation): void; end(): void; getSessionId(): Observable; postActivity(activity: Activity): Observable; private postMessageWithAttachments; private catchPostError; private catchExpiredToken; private pollingGetActivity$; private observableFromActivityGroup; private webSocketActivity$; private getRetryDelay; private observableWebSocket; private reconnectToConversation; private commonHeaders; private getBotAgent; setUserId(userId: string): void; private parseToken; }