/// import { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios'; import WebSocket from 'isomorphic-ws'; import { Channel } from './channel'; import { ClientState } from './client_state'; import { StableWSConnection } from './connection'; import { TokenManager } from './token_manager'; import { WSConnectionFallback } from './connection_fallback'; import { APIResponse, AppSettings, AppSettingsAPIResponse, BaseDeviceFields, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BlockList, BlockListResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CustomPermissionOptions, DeleteCommandResponse, Device, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, FlagMessageResponse, FlagUserResponse, GetChannelTypeResponse, GetCommandResponse, GetRateLimitsResponse, ListChannelResponse, ListCommandsResponse, Logger, MarkChannelsReadOptions, MessageFilters, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PushProvider, PushProviderID, PushProviderConfig, PushProviderUpsertResponse, PushProviderListResponse, ReactionResponse, SearchOptions, SearchAPIResponse, SendFileAPIResponse, StreamChatOptions, TestPushDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, SegmentData, Segment, Campaign, CampaignData, OGAttachment, TaskStatus, DeleteUserOptions, TaskResponse, ExtendableGenerics, DefaultGenerics, ReviewFlagReportResponse, FlagReportsFilters, FlagReportsResponse, ReviewFlagReportOptions, FlagReportsPaginationOptions, ExportUsersRequest, ExportUsersResponse, CreateImportResponse, CreateImportURLResponse, GetImportResponse, ListImportsResponse, ListImportsPaginationOptions, FlagsFilters, FlagsPaginationOptions, FlagsResponse } from './types'; import { InsightMetrics } from './insights'; export declare class StreamChat { private static _instance?; _user?: OwnUserResponse | UserResponse; activeChannels: { [key: string]: Channel; }; anonymous: boolean; axiosInstance: AxiosInstance; baseURL?: string; browser: boolean; cleaningIntervalRef?: NodeJS.Timeout; clientID?: string; configs: Configs; key: string; listeners: { [key: string]: Array<(event: Event) => void>; }; logger: Logger; /** * When network is recovered, we re-query the active channels on client. But in single query, you can recover * only 30 channels. So its not guaranteed that all the channels in activeChannels object have updated state. * Thus in UI sdks, state recovery is managed by components themselves, they don't rely on js client for this. * * `recoverStateOnReconnect` parameter can be used in such cases, to disable state recovery within js client. * When false, user/consumer of this client will need to make sure all the channels present on UI by * manually calling queryChannels endpoint. */ recoverStateOnReconnect?: boolean; mutedChannels: ChannelMute[]; mutedUsers: Mute[]; node: boolean; options: StreamChatOptions; 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; /** * Initialize a client * * **Only use constructor for advanced usages. It is strongly advised to use `StreamChat.getInstance()` instead of `new StreamChat()` to reduce integration issues due to multiple WebSocket connections** * @param {string} key - the api key * @param {string} [secret] - the api secret * @param {StreamChatOptions} [options] - additional options, here you can pass custom options to axios instance * @param {boolean} [options.browser] - enforce the client to be in browser mode * @param {boolean} [options.warmUp] - default to false, if true, client will open a connection as soon as possible to speed up following requests * @param {Logger} [options.Logger] - custom logger * @param {number} [options.timeout] - default to 3000 * @param {httpsAgent} [options.httpsAgent] - custom httpsAgent, in node it's default to https.agent() * @example initialize the client in user mode * new StreamChat('api_key') * @example initialize the client in user mode with options * new StreamChat('api_key', { warmUp:true, timeout:5000 }) * @example secret is optional and only used in server side mode * new StreamChat('api_key', "secret", { httpsAgent: customAgent }) */ constructor(key: string, options?: StreamChatOptions); constructor(key: string, secret?: string, options?: StreamChatOptions); /** * Get a client instance * * This function always returns the same Client instance to avoid issues raised by multiple Client and WS connections * * **After the first call, the client configuration will not change if the key or options parameters change** * * @param {string} key - the api key * @param {string} [secret] - the api secret * @param {StreamChatOptions} [options] - additional options, here you can pass custom options to axios instance * @param {boolean} [options.browser] - enforce the client to be in browser mode * @param {boolean} [options.warmUp] - default to false, if true, client will open a connection as soon as possible to speed up following requests * @param {Logger} [options.Logger] - custom logger * @param {number} [options.timeout] - default to 3000 * @param {httpsAgent} [options.httpsAgent] - custom httpsAgent, in node it's default to https.agent() * @example initialize the client in user mode * StreamChat.getInstance('api_key') * @example initialize the client in user mode with options * StreamChat.getInstance('api_key', { timeout:5000 }) * @example secret is optional and only used in server side mode * StreamChat.getInstance('api_key', "secret", { httpsAgent: customAgent }) */ static getInstance(key: string, options?: StreamChatOptions): StreamChat; static getInstance(key: string, secret?: string, options?: StreamChatOptions): StreamChat; devToken(userID: string): string; getAuthType(): "anonymous" | "jwt"; setBaseURL(baseURL: string): void; _getConnectionID: () => string | undefined; _hasConnectionID: () => boolean; /** * connectUser - Set the current user and open a WebSocket connection * * @param {OwnUserResponse | UserResponse} user Data about this user. IE {name: "john"} * @param {TokenOrProvider} userTokenOrProvider Token or provider * * @return {ConnectAPIResponse} Returns a promise that resolves when the connection is setup */ connectUser: (user: OwnUserResponse | UserResponse, userTokenOrProvider: TokenOrProvider) => Promise>; /** * @deprecated Please use connectUser() function instead. Its naming is more consistent with its functionality. * * setUser - Set the current user and open a WebSocket connection * * @param {OwnUserResponse | UserResponse} user Data about this user. IE {name: "john"} * @param {TokenOrProvider} userTokenOrProvider Token or provider * * @return {ConnectAPIResponse} Returns a promise that resolves when the connection is setup */ setUser: (user: OwnUserResponse | UserResponse, userTokenOrProvider: TokenOrProvider) => Promise>; _setToken: (user: UserResponse, userTokenOrProvider: TokenOrProvider) => Promise; _setUser(user: OwnUserResponse | UserResponse): void; /** * Disconnects the websocket connection, without removing the user set on client. * client.closeConnection will not trigger default auto-retry mechanism for reconnection. You need * to call client.openConnection to reconnect to websocket. * * This is mainly useful on mobile side. You can only receive push notifications * if you don't have active websocket connection. * So when your app goes to background, you can call `client.closeConnection`. * And when app comes back to foreground, call `client.openConnection`. * * @param timeout Max number of ms, to wait for close event of websocket, before forcefully assuming succesful disconnection. * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent */ closeConnection: (timeout?: number | undefined) => Promise; /** * Creates a new WebSocket connection with the current user. Returns empty promise, if there is an active connection */ openConnection: () => Promise>; /** * @deprecated Please use client.openConnction instead. * @private * * Creates a new websocket connection with current user. */ _setupConnection: () => Promise>; /** * updateAppSettings - updates application settings * * @param {AppSettings} options App settings. * IE: { "apn_config": { "auth_type": "token", "auth_key": fs.readFileSync( './apn-push-auth-key.p8', 'utf-8', ), "key_id": "keyid", "team_id": "teamid", //either ALL these 3 "notification_template": "notification handlebars template", "bundle_id": "com.apple.your.app", "development": true }, "firebase_config": { "server_key": "server key from fcm", "notification_template": "notification handlebars template" "data_template": "data handlebars template" }, "webhook_url": "https://acme.com/my/awesome/webhook/" } */ updateAppSettings(options: AppSettings): Promise; _normalizeDate: (before: Date | string | null) => string | null; /** * Revokes all tokens on application level issued before given time */ revokeTokens(before: Date | string | null): Promise; /** * Revokes token for a user issued before given time */ revokeUserToken(userID: string, before?: Date | string | null): Promise; }; }>; /** * Revokes tokens for a list of users issued before given time */ revokeUsersToken(userIDs: string[], before?: Date | string | null): Promise; }; }>; /** * getAppSettings - retrieves application settings */ getAppSettings(): Promise>; /** * testPushSettings - Tests the push settings for a user with a random chat message and the configured push templates * * @param {string} userID User ID. If user has no devices, it will error * @param {TestPushDataInput} [data] Overrides for push templates/message used * IE: { messageID: 'id-of-message', // will error if message does not exist apnTemplate: '{}', // if app doesn't have apn configured it will error firebaseTemplate: '{}', // if app doesn't have firebase configured it will error firebaseDataTemplate: '{}', // if app doesn't have firebase configured it will error skipDevices: true, // skip config/device checks and sending to real devices pushProviderName: 'staging' // one of your configured push providers pushProviderType: 'apn' // one of supported provider types } */ testPushSettings(userID: string, data?: TestPushDataInput): Promise; /** * testSQSSettings - Tests that the given or configured SQS configuration is valid * * @param {TestSQSDataInput} [data] Overrides SQS settings for testing if needed * IE: { sqs_key: 'auth_key', sqs_secret: 'auth_secret', sqs_url: 'url_to_queue', } */ testSQSSettings(data?: TestSQSDataInput): Promise; /** * Disconnects the websocket and removes the user from client. * * @param timeout Max number of ms, to wait for close event of websocket, before forcefully assuming successful disconnection. * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent */ disconnectUser: (timeout?: number | undefined) => Promise; /** * * @deprecated Please use client.disconnectUser instead. * * Disconnects the websocket and removes the user from client. */ disconnect: (timeout?: number | undefined) => Promise; /** * connectAnonymousUser - Set an anonymous user and open a WebSocket connection */ connectAnonymousUser: () => Promise>; /** * @deprecated Please use connectAnonymousUser. Its naming is more consistent with its functionality. */ setAnonymousUser: () => Promise>; /** * setGuestUser - Setup a temporary guest user * * @param {UserResponse} user Data about this user. IE {name: "john"} * * @return {ConnectAPIResponse} Returns a promise that resolves when the connection is setup */ setGuestUser(user: UserResponse): Promise>; /** * createToken - Creates a token to authenticate this user. This function is used server side. * The resulting token should be passed to the client side when the users registers or logs in * * @param {string} userID The User ID * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch * * @return {string} Returns a token */ createToken(userID: string, exp?: number, iat?: number): string; /** * on - Listen to events on all channels and users your watching * * client.on('message.new', event => {console.log("my new message", event, channel.state.messages)}) * or * client.on(event => {console.log(event.type)}) * * @param {EventHandler | string} callbackOrString The event type to listen for (optional) * @param {EventHandler} [callbackOrNothing] The callback to call * * @return {{ unsubscribe: () => void }} Description */ on(callback: EventHandler): { unsubscribe: () => void; }; on(eventType: string, callback: EventHandler): { unsubscribe: () => void; }; /** * off - Remove the event handler * */ 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): Error & { code?: number | undefined; response?: AxiosResponse | undefined; status?: number | undefined; }; handleResponse(response: AxiosResponse): T; dispatchEvent: (event: Event) => void; handleEvent: (messageEvent: WebSocket.MessageEvent) => void; /** * Updates the members and watchers of the currently active channels that contain this user * * @param {UserResponse} user */ _updateMemberWatcherReferences: (user: UserResponse) => void; /** * @deprecated Please _updateMemberWatcherReferences instead. * @private */ _updateUserReferences: (user: UserResponse) => void; /** * @private * * Updates the messages from the currently active channels that contain this user, * with updated user object. * * @param {UserResponse} user */ _updateUserMessageReferences: (user: UserResponse) => void; /** * @private * * Deletes the messages from the currently active channels that contain this user * * If hardDelete is true, all the content of message will be stripped down. * Otherwise, only 'message.type' will be set as 'deleted'. * * @param {UserResponse} user * @param {boolean} hardDelete */ _deleteUserMessageReference: (user: UserResponse, hardDelete?: boolean) => void; /** * @private * * Handle following user related events: * - user.presence.changed * - user.updated * - user.deleted * * @param {Event} event */ _handleUserEvent: (event: Event) => void; _handleClientEvent(event: Event): (() => void)[]; _muteStatus(cid: string): { muted: boolean; createdAt: Date; expiresAt: Date | null; } | { muted: boolean; createdAt: null; expiresAt: null; }; _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} * * @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[]>; /** * 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; }>; /** * 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(channelState: ChannelAPIResponse): 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; }>; reactivateUser(userID: string, options?: { created_by_id?: string; name?: string; restore_messages?: boolean; }): Promise; }>; deactivateUser(userID: string, options?: { created_by_id?: string; mark_messages_deleted?: boolean; }): 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} */ userMuteStatus(targetID: string): 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>; /** * _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 * * 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} targetMessageID * @param {string} [options.user_id] currentUserID, only used with serverside auth * @returns {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; text?: string | undefined; user?: UserResponse | null | undefined; user_id?: string | undefined; } & { args?: string | undefined; channel?: import("./types").ChannelResponse | undefined; cid?: string | undefined; command?: string | undefined; command_info?: { name?: string | undefined; } | undefined; created_at?: string | undefined; deleted_at?: string | undefined; i18n?: (import("./types").RequireAtLeastOne> & { language: import("./types").TranslationLanguages; }) | undefined; latest_reactions?: ReactionResponse[] | undefined; mentioned_users?: UserResponse[] | 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; silent?: boolean | undefined; status?: string | undefined; thread_participants?: UserResponse[] | undefined; type?: import("./types").MessageLabel | 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?: { skip_enrich_url?: boolean; }): 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?: { skip_enrich_url?: boolean; }): Promise>; deleteMessage(messageID: string, hardDelete?: boolean): Promise; }>; getMessage(messageID: string): 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; verifyWebhook(requestBody: string, xSignature: string): boolean; /** getPermission - gets the definition for a permission * * @param {string} name * @returns {Promise} */ getPermission(name: string): Promise; /** createPermission - creates a custom permission * * @param {CustomPermissionOptions} permissionData the permission data * @returns {Promise} */ createPermission(permissionData: CustomPermissionOptions): Promise; /** updatePermission - updates an existing custom permission * * @param {string} id * @param {Omit} permissionData the permission data * @returns {Promise} */ updatePermission(id: string, permissionData: Omit): Promise; /** deletePermission - deletes a custom permission * * @param {string} name * @returns {Promise} */ deletePermission(name: string): Promise; /** listPermissions - returns the list of all permissions for this application * * @returns {Promise} */ listPermissions(): Promise; /** createRole - creates a custom role * * @param {string} name the new role name * @returns {Promise} */ createRole(name: string): Promise; /** listRoles - returns the list of all roles for this application * * @returns {Promise} */ listRoles(): Promise; /** deleteRole - deletes a custom role * * @param {string} name the role name * @returns {Promise} */ deleteRole(name: string): Promise; /** sync - returns all events that happened for a list of channels since last sync * @param {string[]} channel_cids list of channel CIDs * @param {string} last_sync_at last time the user was online and in sync. RFC3339 ie. "2020-05-06T15:05:01.207Z" */ sync(channel_cids: string[], last_sync_at: string): Promise[]; }>; /** * sendUserCustomEvent - Send a custom event to a user * * @param {string} targetUserID target user id * @param {UserCustomEvent} event for example {type: 'friendship-request'} * * @return {Promise} The Server Response */ sendUserCustomEvent(targetUserID: string, event: UserCustomEvent): Promise; createBlockList(blockList: BlockList): Promise; listBlockLists(): Promise; getBlockList(name: string): Promise; updateBlockList(name: string, data: { words: string[]; }): Promise; deleteBlockList(name: string): Promise; exportChannels(request: Array, options?: ExportChannelOptions): Promise; exportUsers(request: ExportUsersRequest): Promise; exportChannel(request: ExportChannelRequest, options?: ExportChannelOptions): Promise; getExportChannelStatus(id: string): Promise; /** * createSegment - Creates a Campaign Segment * * @param {SegmentData} params Segment data * * @return {Segment} The Created Segment */ createSegment(params: SegmentData): Promise; /** * getSegment - Get a Campaign Segment * * @param {string} id Segment ID * * @return {Segment} A Segment */ getSegment(id: string): Promise; /** * listSegments - List Campaign Segments * * * @return {Segment[]} Segments */ listSegments(options: { limit?: number; offset?: number; }): Promise; /** * updateSegment - Update a Campaign Segment * * @param {string} id Segment ID * @param {Partial} params Segment data * * @return {Segment} Updated Segment */ updateSegment(id: string, params: Partial): Promise; /** * deleteSegment - Delete a Campaign Segment * * @param {string} id Segment ID * * @return {Promise} The Server Response */ deleteSegment(id: string): Promise; /** * createCampaign - Creates a Campaign * * @param {CampaignData} params Campaign data * * @return {Campaign} The Created Campaign */ createCampaign(params: CampaignData): Promise; /** * getCampaign - Get a Campaign * * @param {string} id Campaign ID * * @return {Campaign} A Campaign */ getCampaign(id: string): Promise; /** * listCampaigns - List Campaigns * * * @return {Campaign[]} Campaigns */ listCampaigns(options: { limit?: number; offset?: number; }): Promise; /** * updateCampaign - Update a Campaign * * @param {string} id Campaign ID * @param {Partial} params Campaign data * * @return {Campaign} Updated Campaign */ updateCampaign(id: string, params: Partial): Promise; /** * deleteCampaign - Delete a Campaign * * @param {string} id Campaign ID * * @return {Promise} The Server Response */ deleteCampaign(id: string): Promise; /** * scheduleCampaign - Schedule a Campaign * * @param {string} id Campaign ID * @param {{sendAt: number}} params Schedule params * * @return {Campaign} Scheduled Campaign */ scheduleCampaign(id: string, params: { sendAt: number; }): Promise; /** * stopCampaign - Stop a Campaign * * @param {string} id Campaign ID * * @return {Campaign} Stopped Campaign */ stopCampaign(id: string): Promise; /** * resumeCampaign - Resume a Campaign * * @param {string} id Campaign ID * * @return {Campaign} Resumed Campaign */ resumeCampaign(id: string): Promise; /** * testCampaign - Test a Campaign * * @param {string} id Campaign ID * @param {{users: string[]}} params Test params * @return {Campaign} Test Campaign */ testCampaign(id: string, params: { users: string[]; }): Promise; /** * enrichURL - Get OpenGraph data of the given link * * @param {string} url link * @return {OGAttachment} OG Attachment */ enrichURL(url: string): Promise; /** * getTask - Gets status of a long running task * * @param {string} id Task ID * * @return {TaskStatus} The task status */ getTask(id: string): Promise; /** * deleteChannels - Deletes a list of channel * * @param {string[]} cids Channel CIDs * @param {boolean} [options.hard_delete] Defines if the channel is hard deleted or not * * @return {DeleteChannelsResponse} Result of the soft deletion, if server-side, it holds the task ID as well */ deleteChannels(cids: string[], options?: { hard_delete?: boolean; }): Promise; } & Partial>; /** * deleteUsers - Batch Delete Users * * @param {string[]} user_ids which users to delete * @param {DeleteUserOptions} options Configuration how to delete users * * @return {APIResponse} A task ID */ deleteUsers(user_ids: string[], options: DeleteUserOptions): Promise; /** * _createImportURL - Create an Import upload url. * * 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} filename filename of uploaded data * * @return {APIResponse & CreateImportResponse} An ImportTask */ _createImportURL(filename: string): Promise; /** * _createImport - Create an Import Task. * * 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} path path of uploaded data * * @return {APIResponse & CreateImportResponse} An ImportTask */ _createImport(path: string): Promise; /** * _getImport - Get an Import Task. * * 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 id of Import Task * * @return {APIResponse & GetImportResponse} An ImportTask */ _getImport(id: string): Promise; /** * _listImports - Lists Import Tasks. * * 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 {ListImportsPaginationOptions} options pagination options * * @return {APIResponse & ListImportsResponse} An ImportTask */ _listImports(options: ListImportsPaginationOptions): Promise; /** * upsertPushProvider - Create or Update a push provider * * Note: Works only for v2 push version is enabled on app settings. * * @param {PushProviderConfig} configuration of the provider you want to create or update * * @return {APIResponse & PushProviderUpsertResponse} A push provider */ upsertPushProvider(pushProvider: PushProviderConfig): Promise; /** * deletePushProvider - Delete a push provider * * Note: Works only for v2 push version is enabled on app settings. * * @param {PushProviderID} type and foreign id of the push provider to be deleted * * @return {APIResponse} An API response */ deletePushProvider({ type, name }: PushProviderID): Promise; /** * listPushProviders - Get all push providers in the app * * Note: Works only for v2 push version is enabled on app settings. * * @return {APIResponse & PushProviderListResponse} A push provider */ listPushProviders(): Promise; } //# sourceMappingURL=client.d.ts.map