import { ApplicationCancelToken } from './asyncTypesV2'; import { ApplicationChannelList } from './channelTypesV2'; import { ApplicationCommentList } from './commentTypesV2'; import { ApplicationCompany } from './companyTypesV2'; import { ApplicationConversation, ApplicationConversationStatus, ApplicationSingleConversation } from './conversationTypesV2'; import { ApplicationDraft, ApplicationDraftTemplate, ApplicationDraftUpdate } from './draftTypesV2'; import { EntryPointData, EntryPointTypesEnum } from './entryPointTypesV2'; import { HttpRequest, HttpResponse } from './httpTypesV2'; import { ApplicationAttachmentId, ApplicationCommentId, ApplicationConversationId, ApplicationDraftId, ApplicationInboxId, ApplicationMessageId, ApplicationTagId, ApplicationTeammateId, ApplicationTopicId } from './idTypesV2'; import { ApplicationInboxList } from './inboxTypesV2'; import { ApplicationLink } from './linkTypesV2'; import { ApplicationMessageList } from './messageTypesV2'; import { ApplicationPaginationToken } from './paginationTypesV2'; import { ApplicationRecipientList } from './recipientTypesV2'; import { HttpRelayRequest } from './relayTypesV2'; import { ApplicationTagList } from './tagTypesV2'; import { ApplicationTeammate, ApplicationTeammateList } from './teammateTypesV2'; import { ApplicationTicketStatusList } from './ticketStatusesTypesV2'; import { ApplicationTopic } from './topicTypesV2'; import { Widget, WidgetTemplate } from './widgetTypesV2'; export declare enum ApplicationAuthenticationStatusesEnum { AUTHORIZED = "authorized" } export interface ApplicationContextBase { /** Unique ID for this context. */ id: string; /** Unique ID of the Entry Point this context was created from. */ entryPointId: string; /** Unique ID of the component that hosts this entry point. */ hostId: string; /** List of function names supported by this context object with their arity. */ functionArities: { [K: string]: number; }; /** Current teammate's preferences for this application. */ preferences: object; /** Current teammate's authentication. */ authentication: { status?: ApplicationAuthenticationStatusesEnum; }; /** Current teammate. */ teammate: ApplicationTeammate; /** Current company. */ company: ApplicationCompany; /** * Create a new Widget for the current context. * @param template Definition of the Widget to create. * @param cancelToken Cancel the creation of the Widget. * @returns Newly created Widget. */ createWidget(template: WidgetTemplate, cancelToken?: ApplicationCancelToken): Promise; /** * Destroy an existing Widget. * @param widgetId ID of the Widget to destroy. * @param cancelToken Cancel the Widget destruction. */ destroyWidget(widgetId: string, cancelToken?: ApplicationCancelToken): Promise; /** * Send an HTTP request to the private API of the application. * @param request Definition of the HTTP request to run. * @param cancelToken Cancel the HTTP request. * @returns HTTP response. */ sendHttp(request: HttpRequest, cancelToken?: ApplicationCancelToken): Promise; /** * Relay an HTTP request. * @param request Definition of the HTTP request to run. * @param cancelToken Cancel the HTTP request. * @returns HTTP response. */ relayHttp(request: HttpRelayRequest, cancelToken?: ApplicationCancelToken): Promise; /** * Start the authentication flow according to the configured security scheme. */ authenticate(cancelToken?: ApplicationCancelToken): Promise; /** * Delete the credentials stored for the current teammate. */ deauthenticate(cancelToken?: ApplicationCancelToken): Promise; /** * Open a browser window. * @param url URL to navigate to. */ openUrl(url: string, cancelToken?: ApplicationCancelToken): Promise; /** * Open a browser popup. * @param url URL to open. * @param options Optional object to define the properties of the popup. */ openUrlInPopup(url: string, options: { width?: number; height?: number; } | undefined, cancelToken?: ApplicationCancelToken): Promise; /** * Open a conversation in a popup. * @param conversationId Conversation to open. * @param cancelToken Cancel the request. */ openConversationInPopup(conversationId: ApplicationConversationId, cancelToken?: ApplicationCancelToken): Promise; /** * Perform a search in Front for the current teammate. * @param query Search query. * @param cancelToken Cancel the search request. */ search(query: string, cancelToken?: ApplicationCancelToken): Promise; /** * List the teammates of the company. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of teammates. */ listTeammates(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the inboxes accessible by the current teammate. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of inboxes. */ listInboxes(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the channels accessible by the current teammate. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of channels. */ listChannels(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the tags accessible by the current teammate. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of tags. */ listTags(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the ticket statuses accessible by the current teammate. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of ticket statuses. */ listTicketStatuses(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * Create a draft. * @param template Properties of the draft to create * @param cancelToken Cancel the request. * @returns The newly created draft. */ createDraft(template: ApplicationDraftTemplate, cancelToken?: ApplicationCancelToken): Promise; /** * Update a draft. * @param draftId ID of the draft to update. * @param update Properties of the draft to update. * @param cancelToken Cancel the request. */ updateDraft(draftId: ApplicationDraftId, update: ApplicationDraftUpdate, cancelToken?: ApplicationCancelToken): Promise; /** Entry point of the application. */ entryPoint: EntryPointData | undefined; } export declare enum EntryPointNotificationTypesEnum { INCOMING_CALL = "INCOMING_CALL", SUCCESS_MESSAGE = "SUCCESS_MESSAGE", ERROR_MESSAGE = "ERROR_MESSAGE" } export interface IncomingCallContact { name: string; handle?: string; } export interface IncomingCallNotification { type: EntryPointNotificationTypesEnum.INCOMING_CALL; contact?: IncomingCallContact; } export interface SuccessMessageNotification { type: EntryPointNotificationTypesEnum.SUCCESS_MESSAGE; title: string; message: string; } export interface ErrorMessageNotification { type: EntryPointNotificationTypesEnum.ERROR_MESSAGE; title: string; message: string; } export type EntryPointNotification = IncomingCallNotification | SuccessMessageNotification | ErrorMessageNotification; interface NotificationContextBase { /** * Display a notification. This displays both an in-app banner and system notification. * @param entryPointNotification Notification data. * @param cancelToken Cancel the request. * @returns The ID of the created notification. * @beta */ displayNotification(entryPointNotification: EntryPointNotification, cancelToken?: ApplicationCancelToken): Promise; /** * Dismiss a notification based on notification ID. This dismisses the in-app banner. * A caveat is that desktop notifications cannot be dismissed. * @param notificationId The notification ID. * @param cancelToken Cancel the request. * @returns void. * @beta */ dismissNotification(notificationId: string, cancelToken?: ApplicationCancelToken): Promise; } export interface BackgroundContext extends ApplicationContextBase, NotificationContextBase { type: 'background_mode'; } export interface NoConversationContext extends ApplicationContextBase, NotificationContextBase { type: 'noConversation'; } export interface ExistingConversationBaseContext extends ApplicationContextBase, NotificationContextBase { /** * Add a topic to the selected conversations. * @param externalUrl URL of the topic. * @param name Human readable name. * @param cancelToken Cancel the creation of the link. * @returns The added topic. * @deprecated */ addTopic(externalUrl: string, name: string | undefined, cancelToken?: ApplicationCancelToken): Promise; /** * Add a link to the selected conversations. * @param externalUrl URL of the topic. * @param name Human readable name. * @param cancelToken Cancel the creation of the link. * @returns The added link. */ addLink(externalUrl: string, name: string | undefined, cancelToken?: ApplicationCancelToken): Promise; /** * Assign or unassign the selected conversations. * @param teammateId ID of the teammate to assign the conversations to. If null, the conversations will be unassigned. * @param cancelToken Cancel the request. */ assign(teammateId: ApplicationTeammateId | null, cancelToken?: ApplicationCancelToken): Promise; /** * Move the selected conversations to an inbox. * @param inboxId ID of the inbox. * @param cancelToken Cancel the request. */ move(inboxId: ApplicationInboxId, cancelToken?: ApplicationCancelToken): Promise; /** * Set the status of the selected conversations. * @param status Conversation status to apply. * @param cancelToken Cancel the request. */ setStatus(status: ApplicationConversationStatus, cancelToken?: ApplicationCancelToken): Promise; /** * Add the specified tags to the selected conversations. * @param tagIds Tag IDs to add. * @param cancelToken Cancel the request. */ tag(tagIds: ReadonlyArray, cancelToken?: ApplicationCancelToken): Promise; /** * Remove the specified tags from the selected conversations. * @param tagIds Tag IDs to remove. * @param cancelToken Cancel the request. */ untag(tagIds: ReadonlyArray, cancelToken?: ApplicationCancelToken): Promise; /** * Remove the specified link from the conversation. * @param linkId Link ID to remove. * @param cancelToken Cancel the request. */ removeLink(linkId: ApplicationTopicId, cancelToken?: ApplicationCancelToken): Promise; /** * Fetch the current path the user is in within the app. * @param cancelToken Cancel the request. */ fetchPath(cancelToken?: ApplicationCancelToken): Promise; } export interface SingleConversationContext extends ExistingConversationBaseContext { type: 'singleConversation'; /** The selected conversation. */ conversation: ApplicationSingleConversation; /** * Fetch a draft by ID. * @param draftId ID of the draft to fetch. * @param cancelToken Cancel the request. * @returns The draft, if found. */ fetchDraft(draftId: ApplicationDraftId, cancelToken?: ApplicationCancelToken): Promise; /** * List the messages in the current conversation. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of messages. */ listMessages(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the comments in the current conversation. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of comments. */ listComments(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * Download the specified attachment that is attached to a message. To get attachments you will need to use * {@link listMessages} which returns messages with any attachments. * @param messageOrCommentId Message or comment id for the attachment. * @param attachmentId Attachment id to be fetched. * @param cancelToken Cancel the request. * @returns File holding the data of the attachment */ downloadAttachment(messageOrCommentId: ApplicationMessageId | ApplicationCommentId, attachmentId: ApplicationAttachmentId, cancelToken?: ApplicationCancelToken): Promise; /** * List the recipients in the current conversation in the order in which the messages are sent. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of recipients. */ listRecipients(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; } /** * @deprecated * This context has been deprecated and been replaced by the MessageComposerContext. */ export interface NoConversationPopoverContext extends ApplicationContextBase, Pick { type: 'noConversationPopover'; draftId?: ApplicationDraftId; /** * Closes the popover. * * @param cancelToken Cancel the request. */ requestClose(cancelToken?: ApplicationCancelToken): Promise; } /** * @deprecated * This context has been deprecated and been replaced by the MessageComposerContext. */ export interface SingleConversationPopoverContext extends Omit { type: 'singleConversationPopover'; /** * Closes the popover. * * @param cancelToken Cancel the request. */ requestClose(cancelToken?: ApplicationCancelToken): Promise; } export interface MultiConversationsContext extends ExistingConversationBaseContext { type: 'multiConversations'; /** Selected conversations */ conversations: ReadonlyArray; } export type ExistingConversationContext = SingleConversationContext | MultiConversationsContext; export type ConversationContext = NoConversationContext | NoConversationPopoverContext | SingleConversationContext | SingleConversationPopoverContext | MultiConversationsContext; export interface MessageContext extends ApplicationContextBase { type: 'message'; messageId: string; /** * Fetch the current path the user is in within the app. * @param cancelToken Cancel the request. */ fetchPath(cancelToken?: ApplicationCancelToken): Promise; } export interface MessageComposerContext extends ApplicationContextBase { type: 'messageComposer'; draft: ApplicationDraft; /** The conversation will not exist for an unsaved (empty) draft. */ conversation: ApplicationSingleConversation | undefined; /** * Add a link to the conversation if it exists. * @param externalUrl URL of the topic. * @param name Human readable name. * @param cancelToken Cancel the creation of the link. * @returns The added link. */ addLink(externalUrl: string, name: string | undefined, cancelToken?: ApplicationCancelToken): Promise; /** * Assign or unassign the conversation if it exists. * @param teammateId ID of the teammate to assign the conversations to. If null, the conversations will be unassigned. * @param cancelToken Cancel the request. */ assign(teammateId: ApplicationTeammateId | null, cancelToken?: ApplicationCancelToken): Promise; /** * Move the conversation if it exists to an inbox. * @param inboxId ID of the inbox. * @param cancelToken Cancel the request. */ move(inboxId: ApplicationInboxId, cancelToken?: ApplicationCancelToken): Promise; /** * Set the status of the conversation if it exists. * @param status Conversation status to apply. * @param cancelToken Cancel the request. */ setStatus(status: ApplicationConversationStatus, cancelToken?: ApplicationCancelToken): Promise; /** * Add the specified tags to the conversation if it exists. * @param tagIds Tag IDs to add. * @param cancelToken Cancel the request. */ tag(tagIds: ReadonlyArray, cancelToken?: ApplicationCancelToken): Promise; /** * Remove the specified tags from the conversation if it exists. * @param tagIds Tag IDs to remove. * @param cancelToken Cancel the request. */ untag(tagIds: ReadonlyArray, cancelToken?: ApplicationCancelToken): Promise; /** * Remove the specified link from the conversation if it exists. * @param linkId Link ID to remove. * @param cancelToken Cancel the request. */ removeLink(linkId: ApplicationTopicId, cancelToken?: ApplicationCancelToken): Promise; /** * List the messages in the conversation if it exists. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of messages. */ listMessages(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the comments in the conversation if it exists. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of comments. */ listComments(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * List the recipients in the order in which the recipients are sent if the conversation exists. * @param paginationToken Token of the requested page. If omitted, will return the first page of results. * @param cancelToken Cancel the request. * @returns List of recipients. */ listRecipients(paginationToken?: ApplicationPaginationToken, cancelToken?: ApplicationCancelToken): Promise; /** * Download the specified attachment that is attached to the draft. * @param messageOrCommentId Message or comment id for the attachment. * @param attachmentId Attachment id to be fetched. * @param cancelToken Cancel the request. * @returns File holding the data of the attachment */ downloadComposerAttachment(attachmentId: ApplicationAttachmentId, cancelToken?: ApplicationCancelToken): Promise; /** * Close the message composer plugin. */ close(cancelToken?: ApplicationCancelToken): Promise; /** * Close the draft and the composer plugin. * @param cancelToken Cancel the request. */ closeDraft(cancelToken?: ApplicationCancelToken): Promise; } export type ApplicationContext = ConversationContext | MessageContext | MessageComposerContext | BackgroundContext; interface ContextMap { [EntryPointTypesEnum.CONVERSATION_LINK_DROPDOWN]: ExistingConversationContext; [EntryPointTypesEnum.MESSAGE_MORE_DROPDOWN]: MessageContext; [EntryPointTypesEnum.SIDE_PANEL]: ConversationContext | BackgroundContext; [EntryPointTypesEnum.URL]: ConversationContext; [EntryPointTypesEnum.COMPOSER_TOOLBAR]: MessageComposerContext; [EntryPointTypesEnum.CONTACT_HANDLE]: ConversationContext; } export type ContextOf = ContextMap[T]; export {};