///
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import WebSocket from 'isomorphic-ws';
import { Channel } from './room';
import { ClientState } from './belo_chat_state';
import { StableWSConnection } from './connection';
import { TokenManager } from './token_manager';
import { WSConnectionFallback } from './connection_fallback';
import { Campaign } from './campaign';
import { Segment } from './segment';
import { APIErrorResponse, APIResponse, AppSettings, AppSettingsAPIResponse, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BaseDeviceFields, BlockList, BlockListResponse, CampaignResponse, CampaignData, CampaignFilters, CampaignQueryOptions, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelResponse, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSNSResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CreateImportOptions, CreateImportResponse, CreateImportURLResponse, CustomPermissionOptions, DeactivateUsersOptions, DefaultGenerics, DeleteCommandResponse, DeleteUserOptions, Device, EndpointName, ErrorFromResponse, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, ExtendableGenerics, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, GetCallTokenResponse, GetChannelTypeResponse, GetCommandResponse, GetImportResponse, GetMessageAPIResponse, GetRateLimitsResponse, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, Logger, MarkChannelsReadOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PushProvider, PushProviderConfig, PushProviderID, PushProviderListResponse, PushProviderUpsertResponse, QueryChannelsAPIResponse, QuerySegmentsOptions, ReactionResponse, ReactivateUserOptions, ReactivateUsersOptions, ReviewFlagReportOptions, ReviewFlagReportResponse, SearchAPIResponse, SearchOptions, SegmentResponse, SegmentData, SegmentType, SendFileAPIResponse, ErmisChatOptions, SyncOptions, SyncResponse, TaskResponse, TaskStatus, TestPushDataInput, TestSNSDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UpdateMessageOptions, UpdateSegmentData, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, GetThreadAPIResponse, PartialThreadUpdate, QueryThreadsOptions, GetThreadOptions, CampaignSort, SegmentTargetsResponse, QuerySegmentTargetsFilter, SortParam, GetMessageOptions } from './types';
import { InsightMetrics } from './insights';
import { Thread } from './thread';
export declare class ErmisChat {
private static _instance?;
_user?: OwnUserResponse | UserResponse;
activeChannels: {
[key: string]: Channel;
};
anonymous: boolean;
persistUserOnConnectionFailure?: boolean;
axiosInstance: AxiosInstance;
baseURL?: string;
browser: boolean;
cleaningIntervalRef?: NodeJS.Timeout;
clientID?: string;
configs: Configs;
key: string;
listeners: Record) => void>>;
logger: Logger;
recoverStateOnReconnect?: boolean;
mutedChannels: ChannelMute[];
mutedUsers: Mute[];
node: boolean;
options: ErmisChatOptions;
secret?: string;
setUserPromise: ConnectAPIResponse | null;
state: ClientState;
tokenManager: TokenManager;
user?: OwnUserResponse | UserResponse;
userAgent?: string;
userID?: string;
wsBaseURL?: string;
wsConnection: StableWSConnection | null;
wsFallback?: WSConnectionFallback;
wsPromise: ConnectAPIResponse | null;
consecutiveFailures: number;
insightMetrics: InsightMetrics;
defaultWSTimeoutWithFallback: number;
defaultWSTimeout: number;
private nextRequestAbortController;
constructor(key: string, options?: ErmisChatOptions);
constructor(key: string, secret?: string, options?: ErmisChatOptions);
static getInstance(key: string, options?: ErmisChatOptions): ErmisChat;
static getInstance(key: string, secret?: string, options?: ErmisChatOptions): ErmisChat;
devToken(userID: string): string;
getAuthType(): "anonymous" | "jwt";
setBaseURL(baseURL: string): void;
_getConnectionID: () => string | undefined;
_hasConnectionID: () => boolean;
connectUser: (user: OwnUserResponse | UserResponse, userTokenOrProvider: TokenOrProvider) => Promise>;
setUser: (user: OwnUserResponse | UserResponse, userTokenOrProvider: TokenOrProvider) => Promise>;
_setToken: (user: UserResponse, userTokenOrProvider: TokenOrProvider) => Promise;
_setUser(user: OwnUserResponse | UserResponse): void;
closeConnection: (timeout?: number | undefined) => Promise;
openConnection: () => Promise>;
_setupConnection: () => Promise>;
updateAppSettings(options: AppSettings): Promise;
_normalizeDate: (before: Date | string | null) => string | null;
revokeTokens(before: Date | string | null): Promise;
revokeUserToken(userID: string, before?: Date | string | null): Promise;
};
}>;
revokeUsersToken(userIDs: string[], before?: Date | string | null): Promise;
};
}>;
getAppSettings(): Promise>;
testPushSettings(userID: string, data?: TestPushDataInput): Promise;
testSQSSettings(data?: TestSQSDataInput): Promise;
testSNSSettings(data?: TestSNSDataInput): Promise;
disconnectUser: (timeout?: number | undefined) => Promise;
disconnect: (timeout?: number | undefined) => Promise;
connectAnonymousUser: () => Promise>;
setAnonymousUser: () => Promise>;
setGuestUser(user: UserResponse): Promise>;
createToken(userID: string, exp?: number, iat?: number): string;
on(callback: EventHandler): {
unsubscribe: () => void;
};
on(eventType: string, callback: EventHandler): {
unsubscribe: () => void;
};
off(callback: EventHandler): void;
off(eventType: string, callback: EventHandler): void;
_logApiRequest(type: string, url: string, data: unknown, config: AxiosRequestConfig & {
config?: AxiosRequestConfig & {
maxBodyLength?: number;
};
}): void;
_logApiResponse(type: string, url: string, response: AxiosResponse): void;
_logApiError(type: string, url: string, error: unknown): void;
doAxiosRequest: (type: string, url: string, data?: unknown, options?: AxiosRequestConfig & {
config?: AxiosRequestConfig & {
maxBodyLength?: number;
};
}) => Promise;
get(url: string, params?: AxiosRequestConfig['params']): Promise;
put(url: string, data?: unknown): Promise;
post(url: string, data?: unknown): Promise;
patch(url: string, data?: unknown): Promise;
delete(url: string, params?: AxiosRequestConfig['params']): Promise;
sendFile(url: string, uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse): Promise;
errorFromResponse(response: AxiosResponse): ErrorFromResponse;
handleResponse(response: AxiosResponse): T;
dispatchEvent: (event: Event) => void;
handleEvent: (messageEvent: WebSocket.MessageEvent) => void;
_updateMemberWatcherReferences: (user: UserResponse) => void;
_updateUserReferences: (user: UserResponse) => void;
_updateUserMessageReferences: (user: UserResponse) => void;
_deleteUserMessageReference: (user: UserResponse, hardDelete?: boolean) => void;
_handleUserEvent: (event: Event) => void;
_handleClientEvent(event: Event): (() => void)[];
_callClientListeners: (event: Event) => void;
recoverState: () => Promise;
/**
* @private
*/
connect(): Promise>;
/**
* Check the connectivity with server for warmup purpose.
*
* @private
*/
_sayHi(): void;
/**
* queryUsers - Query users and watch user presence
*
* @param {UserFilters} filterConditions MongoDB style filter conditions
* @param {UserSort} sort Sort options, for instance [{last_active: -1}].
* When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{last_active: -1}, {created_at: 1}]
* @param {UserOptions} options Option object, {presence: true}
*
* @return {Promise<{ users: Array> }>} User Query Response
*/
queryUsers(filterConditions: UserFilters, sort?: UserSort, options?: UserOptions): Promise>;
}>;
/**
* queryBannedUsers - Query user bans
*
* @param {BannedUsersFilters} filterConditions MongoDB style filter conditions
* @param {BannedUsersSort} sort Sort options [{created_at: 1}].
* @param {BannedUsersPaginationOptions} options Option object, {limit: 10, offset:0, exclude_expired_bans: true}
*
* @return {Promise>} Ban Query Response
*/
queryBannedUsers(filterConditions?: BannedUsersFilters, sort?: BannedUsersSort, options?: BannedUsersPaginationOptions): Promise>;
/**
* queryMessageFlags - Query message flags
*
* @param {MessageFlagsFilters} filterConditions MongoDB style filter conditions
* @param {MessageFlagsPaginationOptions} options Option object, {limit: 10, offset:0}
*
* @return {Promise>} Message Flags Response
*/
queryMessageFlags(filterConditions?: MessageFlagsFilters, options?: MessageFlagsPaginationOptions): Promise>;
/**
* queryChannels - Query channels
*
* @param {ChannelFilters} filterConditions object MongoDB style filters
* @param {ChannelSort} [sort] Sort options, for instance {created_at: -1}.
* When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{last_updated: -1}, {created_at: 1}]
* @param {ChannelOptions} [options] Options object
* @param {ChannelStateOptions} [stateOptions] State options object. These options will only be used for state management and won't be sent in the request.
* - stateOptions.skipInitialization - Skips the initialization of the state for the channels matching the ids in the list.
*
* @return {Promise<{ channels: Array>}> } search channels response
*/
queryChannels(filterConditions: ChannelFilters, sort?: ChannelSort, options?: ChannelOptions, stateOptions?: ChannelStateOptions): Promise[]>;
startCall(payload: any): Promise>;
queryFriends(): Promise;
hydrateActiveChannels(channelsFromApi?: ChannelAPIResponse[], stateOptions?: ChannelStateOptions): Channel[];
/**
* search - Query messages
*
* @param {ChannelFilters} filterConditions MongoDB style filter conditions
* @param {MessageFilters | string} query search query or object MongoDB style filters
* @param {SearchOptions} [options] Option object, {user_id: 'tommaso'}
*
* @return {Promise>} search messages response
*/
search(filterConditions: ChannelFilters, query: string | MessageFilters, options?: SearchOptions): Promise>;
/**
* setLocalDevice - Set the device info for the current client(device) that will be sent via WS connection automatically
*
* @param {BaseDeviceFields} device the device object
* @param {string} device.id device id
* @param {string} device.push_provider the push provider
*
*/
setLocalDevice(device: BaseDeviceFields): void;
/**
* addDevice - Adds a push device for a user.
*
* @param {string} id the device id
* @param {PushProvider} push_provider the push provider
* @param {string} [userID] the user id (defaults to current user)
* @param {string} [push_provider_name] user provided push provider name for multi bundle support
*
*/
addDevice(id: string, push_provider: PushProvider, userID?: string, push_provider_name?: string): Promise;
/**
* getDevices - Returns the devices associated with a current user
*
* @param {string} [userID] User ID. Only works on serverside
*
* @return {Device[]} Array of devices
*/
getDevices(userID?: string): Promise[] | undefined;
}>;
/**
* getUnreadCount - Returns unread counts for a single user
*
* @param {string} [userID] User ID.
*
* @return {}
*/
getUnreadCount(userID?: string): Promise;
/**
* getUnreadCountBatch - Returns unread counts for multiple users at once. Only works server side.
*
* @param {string[]} [userIDs] List of user IDs to fetch unread counts for.
*
* @return {}
*/
getUnreadCountBatch(userIDs: string[]): Promise;
/**
* removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
*
* @param {string} id The device id
* @param {string} [userID] The user id. Only specify this for serverside requests
*
*/
removeDevice(id: string, userID?: string): Promise;
/**
* getRateLimits - Returns the rate limits quota and usage for the current app, possibly filter for a specific platform and/or endpoints.
* Only available server-side.
*
* @param {object} [params] The params for the call. If none of the params are set, all limits for all platforms are returned.
* @returns {Promise}
*/
getRateLimits(params?: {
android?: boolean;
endpoints?: EndpointName[];
ios?: boolean;
serverSide?: boolean;
web?: boolean;
}): Promise;
_addChannelConfig({ cid, config }: ChannelResponse): void;
/**
* channel - Returns a new channel with the given type, id and custom data
*
* If you want to create a unique conversation between 2 or more users; you can leave out the ID parameter and provide the list of members.
* Make sure to await channel.create() or channel.watch() before accessing channel functions:
* ie. channel = client.channel("messaging", {members: ["tommaso", "thierry"]})
* await channel.create() to assign an ID to channel
*
* @param {string} channelType The channel type
* @param {string | ChannelData | null} [channelIDOrCustom] The channel ID, you can leave this out if you want to create a conversation channel
* @param {object} [custom] Custom data to attach to the channel
*
* @return {channel} The channel object, initialize it using channel.watch()
*/
channel(channelType: string, channelID?: string | null, custom?: ChannelData): Channel;
channel(channelType: string, custom?: ChannelData): Channel;
/**
* It's a helper method for `client.channel()` method, used to create unique conversation or
* channel based on member list instead of id.
*
* If the channel already exists in `activeChannels` list, then we simply return it, since that
* means the same channel was already requested or created.
*
* Otherwise we create a new instance of Channel class and return it.
*
* @private
*
* @param {string} channelType The channel type
* @param {object} [custom] Custom data to attach to the channel
*
* @return {channel} The channel object, initialize it using channel.watch()
*/
getChannelByMembers: (channelType: string, custom: ChannelData) => Channel;
/**
* Its a helper method for `client.channel()` method, used to channel given the id of channel.
*
* If the channel already exists in `activeChannels` list, then we simply return it, since that
* means the same channel was already requested or created.
*
* Otherwise we create a new instance of Channel class and return it.
*
* @private
*
* @param {string} channelType The channel type
* @param {string} [channelID] The channel ID
* @param {object} [custom] Custom data to attach to the channel
*
* @return {channel} The channel object, initialize it using channel.watch()
*/
getChannelById: (channelType: string, channelID: string, custom: ChannelData) => Channel;
/**
* partialUpdateUser - Update the given user object
*
* @param {PartialUserUpdate} partialUserObject which should contain id and any of "set" or "unset" params;
* example: {id: "user1", set:{field: value}, unset:["field2"]}
*
* @return {Promise<{ users: { [key: string]: UserResponse } }>} list of updated users
*/
partialUpdateUser(partialUserObject: PartialUserUpdate): Promise;
};
}>;
/**
* upsertUsers - Batch upsert the list of users
*
* @param {UserResponse[]} users list of users
*
* @return {Promise<{ users: { [key: string]: UserResponse } }>}
*/
upsertUsers(users: UserResponse[]): Promise;
};
}>;
/**
* @deprecated Please use upsertUsers() function instead.
*
* updateUsers - Batch update the list of users
*
* @param {UserResponse[]} users list of users
* @return {Promise<{ users: { [key: string]: UserResponse } }>}
*/
updateUsers: (users: UserResponse[]) => Promise;
};
}>;
/**
* upsertUser - Update or Create the given user object
*
* @param {UserResponse} userObject user object, the only required field is the user id. IE {id: "myuser"} is valid
*
* @return {Promise<{ users: { [key: string]: UserResponse } }>}
*/
upsertUser(userObject: UserResponse): Promise;
};
}>;
/**
* @deprecated Please use upsertUser() function instead.
*
* updateUser - Update or Create the given user object
*
* @param {UserResponse} userObject user object, the only required field is the user id. IE {id: "myuser"} is valid
* @return {Promise<{ users: { [key: string]: UserResponse } }>}
*/
updateUser: (userObject: UserResponse) => Promise;
};
}>;
/**
* partialUpdateUsers - Batch partial update of users
*
* @param {PartialUserUpdate[]} users list of partial update requests
*
* @return {Promise<{ users: { [key: string]: UserResponse } }>}
*/
partialUpdateUsers(users: PartialUserUpdate[]): Promise;
};
}>;
deleteUser(userID: string, params?: {
delete_conversation_channels?: boolean;
hard_delete?: boolean;
mark_messages_deleted?: boolean;
}): Promise;
} & {
task_id?: string | undefined;
}>;
/**
* restoreUsers - Restore soft deleted users
*
* @param {string[]} user_ids which users to restore
*
* @return {APIResponse} An API response
*/
restoreUsers(user_ids: string[]): Promise;
/**
* reactivateUser - Reactivate one user
*
* @param {string} userID which user to reactivate
* @param {ReactivateUserOptions} [options]
*
* @return {UserResponse} Reactivated user
*/
reactivateUser(userID: string, options?: ReactivateUserOptions): Promise;
}>;
/**
* reactivateUsers - Reactivate many users asynchronously
*
* @param {string[]} user_ids which users to reactivate
* @param {ReactivateUsersOptions} [options]
*
* @return {TaskResponse} A task ID
*/
reactivateUsers(user_ids: string[], options?: ReactivateUsersOptions): Promise;
/**
* deactivateUser - Deactivate one user
*
* @param {string} userID which user to deactivate
* @param {DeactivateUsersOptions} [options]
*
* @return {UserResponse} Deactivated user
*/
deactivateUser(userID: string, options?: DeactivateUsersOptions): Promise;
}>;
/**
* deactivateUsers - Deactivate many users asynchronously
*
* @param {string[]} user_ids which users to deactivate
* @param {DeactivateUsersOptions} [options]
*
* @return {TaskResponse} A task ID
*/
deactivateUsers(user_ids: string[], options?: DeactivateUsersOptions): Promise;
exportUser(userID: string, options?: Record): Promise[];
reactions: ReactionResponse[];
user: UserResponse;
}>;
/** banUser - bans a user from all channels
*
* @param {string} targetUserID
* @param {BanUserOptions} [options]
* @returns {Promise}
*/
banUser(targetUserID: string, options?: BanUserOptions): Promise;
/** unbanUser - revoke global ban for a user
*
* @param {string} targetUserID
* @param {UnBanUserOptions} [options]
* @returns {Promise}
*/
unbanUser(targetUserID: string, options?: UnBanUserOptions): Promise;
/** shadowBan - shadow bans a user from all channels
*
* @param {string} targetUserID
* @param {BanUserOptions} [options]
* @returns {Promise}
*/
shadowBan(targetUserID: string, options?: BanUserOptions): Promise;
/** removeShadowBan - revoke global shadow ban for a user
*
* @param {string} targetUserID
* @param {UnBanUserOptions} [options]
* @returns {Promise}
*/
removeShadowBan(targetUserID: string, options?: UnBanUserOptions): Promise;
/** muteUser - mutes a user
*
* @param {string} targetID
* @param {string} [userID] Only used with serverside auth
* @param {MuteUserOptions} [options]
* @returns {Promise>}
*/
muteUser(targetID: string, userID?: string, options?: MuteUserOptions): Promise>;
/** unmuteUser - unmutes a user
*
* @param {string} targetID
* @param {string} [currentUserID] Only used with serverside auth
* @returns {Promise}
*/
unmuteUser(targetID: string, currentUserID?: string): Promise;
/** userMuteStatus - check if a user is muted or not, can be used after connectUser() is called
*
* @param {string} targetID
* @returns {boolean}
*/
/**
* flagMessage - flag a message
* @param {string} targetMessageID
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @returns {Promise}
*/
flagMessage(targetMessageID: string, options?: {
user_id?: string;
}): Promise>;
/**
* flagUser - flag a user
* @param {string} targetID
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @returns {Promise}
*/
flagUser(targetID: string, options?: {
user_id?: string;
}): Promise>;
/**
* unflagMessage - unflag a message
* @param {string} targetMessageID
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @returns {Promise}
*/
unflagMessage(targetMessageID: string, options?: {
user_id?: string;
}): Promise>;
/**
* unflagUser - unflag a user
* @param {string} targetID
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @returns {Promise}
*/
unflagUser(targetID: string, options?: {
user_id?: string;
}): Promise>;
/**
* getCallToken - retrieves the auth token needed to join a call
*
* @param {string} callID
* @param {object} options
* @returns {Promise}
*/
getCallToken(callID: string, options?: {
user_id?: string;
}): Promise;
/**
* _queryFlags - Query flags.
*
* Note: Do not use this.
* It is present for internal usage only.
* This function can, and will, break and/or be removed at any point in time.
*
* @private
* @param {FlagsFilters} filterConditions MongoDB style filter conditions
* @param {FlagsPaginationOptions} options Option object, {limit: 10, offset:0}
*
* @return {Promise>} Flags Response
*/
_queryFlags(filterConditions?: FlagsFilters, options?: FlagsPaginationOptions): Promise>;
/**
* _queryFlagReports - Query flag reports.
*
* Note: Do not use this.
* It is present for internal usage only.
* This function can, and will, break and/or be removed at any point in time.
*
* @private
* @param {FlagReportsFilters} filterConditions MongoDB style filter conditions
* @param {FlagReportsPaginationOptions} options Option object, {limit: 10, offset:0}
*
* @return {Promise>} Flag Reports Response
*/
_queryFlagReports(filterConditions?: FlagReportsFilters, options?: FlagReportsPaginationOptions): Promise>;
/**
* _reviewFlagReport - review flag report
*
* Note: Do not use this.
* It is present for internal usage only.
* This function can, and will, break and/or be removed at any point in time.
*
* @private
* @param {string} [id] flag report to review
* @param {string} [reviewResult] flag report review result
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @param {string} [options.review_details] custom information about review result
* @returns {Promise>}
*/
_reviewFlagReport(id: string, reviewResult: string, options?: ReviewFlagReportOptions): Promise>;
/**
* unblockMessage - unblocks message blocked by automod
*
*
* @param {string} targetMessageID
* @param {string} [options.user_id] currentUserID, only used with serverside auth
* @returns {Promise}
*/
unblockMessage(targetMessageID: string, options?: {
user_id?: string;
}): Promise;
_unblockMessage: (targetMessageID: string, options?: {
user_id?: string;
}) => Promise;
/**
* @deprecated use markChannelsRead instead
*
* markAllRead - marks all channels for this user as read
* @param {MarkAllReadOptions} [data]
*
* @return {Promise}
*/
markAllRead: (data?: MarkChannelsReadOptions) => Promise;
/**
* markChannelsRead - marks channels read -
* it accepts a map of cid:messageid pairs, if messageid is empty, the whole channel will be marked as read
*
* @param {MarkChannelsReadOptions } [data]
*
* @return {Promise}
*/
markChannelsRead(data?: MarkChannelsReadOptions): Promise;
createCommand(data: CreateCommandOptions): Promise>;
getCommand(name: string): Promise>;
updateCommand(name: string, data: UpdateCommandOptions): Promise>;
deleteCommand(name: string): Promise>;
listCommands(): Promise>;
createChannelType(data: CreateChannelOptions): Promise>;
getChannelType(channelType: string): Promise>;
updateChannelType(channelType: string, data: UpdateChannelOptions): Promise>;
deleteChannelType(channelType: string): Promise;
listChannelTypes(): Promise>;
/**
* translateMessage - adds the translation to the message
*
* @param {string} messageId
* @param {string} language
*
* @return {MessageResponse} Response that includes the message
*/
translateMessage(messageId: string, language: string): Promise[] | undefined;
html?: string | undefined;
mml?: string | undefined;
parent_id?: string | undefined;
pin_expires?: string | null | undefined;
pinned?: boolean | undefined;
pinned_at?: string | null | undefined;
quoted_message_id?: string | undefined;
show_in_channel?: boolean | undefined;
silent?: boolean | undefined;
text?: string | undefined;
user?: UserResponse | null | undefined;
user_id?: string | undefined;
} & {
type: import("./types").MessageLabel;
args?: string | undefined;
channel?: ChannelResponse | undefined;
cid?: string | undefined;
command?: string | undefined;
command_info?: {
name?: string | undefined;
} | undefined;
created_at?: string | undefined;
deleted_at?: string | undefined;
deleted_reply_count?: number | undefined;
i18n?: (import("./types").RequireAtLeastOne> & {
language: import("./types").TranslationLanguages;
}) | undefined;
latest_reactions?: ReactionResponse[] | undefined;
mentioned_users?: UserResponse[] | undefined;
message_text_updated_at?: string | undefined;
moderation_details?: import("./types").ModerationDetailsResponse | undefined;
own_reactions?: ReactionResponse[] | null | undefined;
pin_expires?: string | null | undefined;
pinned_at?: string | null | undefined;
pinned_by?: UserResponse | null | undefined;
reaction_counts?: {
[key: string]: number;
} | null | undefined;
reaction_scores?: {
[key: string]: number;
} | null | undefined;
reply_count?: number | undefined;
shadowed?: boolean | undefined;
status?: string | undefined;
thread_participants?: UserResponse[] | undefined;
updated_at?: string | undefined;
} & {
quoted_message?: import("./types").MessageResponseBase | undefined;
}>;
/**
* _normalizeExpiration - transforms expiration value into ISO string
* @param {undefined|null|number|string|Date} timeoutOrExpirationDate expiration date or timeout. Use number type to set timeout in seconds, string or Date to set exact expiration date
*/
_normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
/**
* _messageId - extracts string message id from either message object or message id
* @param {string | { id: string }} messageOrMessageId message object or message id
* @param {string} errorText error message to report in case of message id absence
*/
_validateAndGetMessageId(messageOrMessageId: string | {
id: string;
}, errorText: string): string;
/**
* pinMessage - pins the message
* @param {string | { id: string }} messageOrMessageId message object or message id
* @param {undefined|null|number|string|Date} timeoutOrExpirationDate expiration date or timeout. Use number type to set timeout in seconds, string or Date to set exact expiration date
* @param {undefined|string | { id: string }} [pinnedBy] who will appear as a user who pinned a message. Only for server-side use. Provide `undefined` when pinning message client-side
* @param {undefined|number|string|Date} pinnedAt date when message should be pinned. It affects the order of pinned messages. Use negative number to set relative time in the past, string or Date to set exact date of pin
*/
pinMessage(messageOrMessageId: string | {
id: string;
}, timeoutOrExpirationDate?: null | number | string | Date, pinnedBy?: string | {
id: string;
}, pinnedAt?: number | string | Date): Promise>;
/**
* unpinMessage - unpins the message that was previously pinned
* @param {string | { id: string }} messageOrMessageId message object or message id
* @param {string | { id: string }} [userId]
*/
unpinMessage(messageOrMessageId: string | {
id: string;
}, userId?: string | {
id: string;
}): Promise>;
/**
* updateMessage - Update the given message
*
* @param {Omit, 'mentioned_users'> & { mentioned_users?: string[] }} message object, id needs to be specified
* @param {string | { id: string }} [userId]
* @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
*
* @return {{ message: MessageResponse }} Response that includes the message
*/
updateMessage(message: UpdatedMessage, userId?: string | {
id: string;
}, options?: UpdateMessageOptions): Promise>;
/**
* partialUpdateMessage - Update the given message id while retaining additional properties
*
* @param {string} id the message id
*
* @param {PartialUpdateMessage} partialMessageObject which should contain id and any of "set" or "unset" params;
* example: {id: "user1", set:{text: "hi"}, unset:["color"]}
* @param {string | { id: string }} [userId]
*
* @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
*
* @return {{ message: MessageResponse }} Response that includes the updated message
*/
partialUpdateMessage(id: string, partialMessageObject: PartialMessageUpdate, userId?: string | {
id: string;
}, options?: UpdateMessageOptions): Promise>;
deleteMessage(messageID: string, hardDelete?: boolean): Promise;
}>;
/**
* undeleteMessage - Undelete a message
*
* undeletes a message that was previous soft deleted. Hard deleted messages
* cannot be undeleted. This is only allowed to be called from server-side
* clients.
*
* @param {string} messageID The id of the message to undelete
* @param {string} userID The id of the user who undeleted the message
*
* @return {{ message: MessageResponse }} Response that includes the message
*/
undeleteMessage(messageID: string, userID: string): Promise;
}>;
getMessage(messageID: string, options?: GetMessageOptions): Promise>;
/**
* queryThreads - returns the list of threads of current user.
*
* @param {QueryThreadsOptions} options Options object for pagination and limiting the participants and replies.
* @param {number} options.limit Limits the number of threads to be returned.
* @param {boolean} options.watch Subscribes the user to the channels of the threads.
* @param {number} options.participant_limit Limits the number of participants returned per threads.
* @param {number} options.reply_limit Limits the number of replies returned per threads.
*
* @returns {{ threads: Thread[], next: string }} Returns the list of threads and the next cursor.
*/
queryThreads(options?: QueryThreadsOptions): Promise<{
threads: Thread[];
next: string | undefined;
}>;
/**
* getThread - returns the thread of a message by its id.
*
* @param {string} messageId The message id
* @param {GetThreadOptions} options Options object for pagination and limiting the participants and replies.
* @param {boolean} options.watch Subscribes the user to the channel of the thread.
* @param {number} options.participant_limit Limits the number of participants returned per threads.
* @param {number} options.reply_limit Limits the number of replies returned per threads.
*
* @returns {Thread} Returns the thread.
*/
getThread(messageId: string, options?: GetThreadOptions): Promise>;
/**
* partialUpdateThread - updates the given thread
*
* @param {string} messageId The id of the thread message which needs to be updated.
* @param {PartialThreadUpdate} partialThreadObject should contain "set" or "unset" params for any of the thread's non-reserved fields.
*
* @returns {GetThreadAPIResponse} Returns the updated thread.
*/
partialUpdateThread(messageId: string, partialThreadObject: PartialThreadUpdate): Promise>;
getUserAgent(): string;
setUserAgent(userAgent: string): void;
/**
* _isUsingServerAuth - Returns true if we're using server side auth
*/
_isUsingServerAuth: () => boolean;
_enrichAxiosOptions(options?: AxiosRequestConfig & {
config?: AxiosRequestConfig;
}): AxiosRequestConfig;
_getToken(): string | null | undefined;
_startCleaning(): void;
/**
* encode ws url payload
* @private
* @returns json string
*/
_buildWSPayload: (client_request_id?: string | undefined) => string;
/**
* checks signature of a request
* @param {string | Buffer} rawBody
* @param {string} signature from HTTP header
* @returns {boolean}
*/
verifyWebhook(requestBody: string | Buffer, xSignature: string): boolean;
/** getPermission - gets the definition for a permission
*
* @param {string} name
* @returns {Promise}
*/
getPermission(name: string): Promise