From 31b0c923368f59c37badf258827536287a000fcd Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 15 Sep 2023 10:13:32 +0200 Subject: [PATCH] feat: declare and export types SendMessageOptions and UpdateMessageOptions --- src/channel.ts | 14 ++------------ src/client.ts | 5 +++-- src/types.ts | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/channel.ts b/src/channel.ts index 59c201270..6aad2b0fd 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -53,6 +53,7 @@ import { UserFilters, UserResponse, QueryChannelAPIResponse, + SendMessageOptions, } from './types'; import { Role } from './permissions'; @@ -168,18 +169,7 @@ export class Channel>} The Server Response */ - async sendMessage( - message: Message, - options?: { - force_moderation?: boolean; - is_pending_message?: boolean; - keep_channel_hidden?: boolean; - pending?: boolean; - pending_message_metadata?: Record; - skip_enrich_url?: boolean; - skip_push?: boolean; - }, - ) { + async sendMessage(message: Message, options?: SendMessageOptions) { const sendMessageResponse = await this.getClient().post>( this._channelURL() + '/message', { diff --git a/src/client.ts b/src/client.ts index be0f4339a..13ac06a1f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -154,6 +154,7 @@ import { UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, + UpdateMessageOptions, UserCustomEvent, UserFilters, UserOptions, @@ -2439,7 +2440,7 @@ export class StreamChat, userId?: string | { id: string }, - options?: { skip_enrich_url?: boolean }, + options?: UpdateMessageOptions, ) { if (!message.id) { throw Error('Please specify the message id when calling updateMessage'); @@ -2510,7 +2511,7 @@ export class StreamChat, userId?: string | { id: string }, - options?: { skip_enrich_url?: boolean }, + options?: UpdateMessageOptions, ) { if (!id) { throw Error('Please specify the message id when calling partialUpdateMessage'); diff --git a/src/types.ts b/src/types.ts index 8f0f4ec1c..861e1a048 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2076,6 +2076,20 @@ export type MessageBase< export type MessageLabel = 'deleted' | 'ephemeral' | 'error' | 'regular' | 'reply' | 'system'; +export type SendMessageOptions = { + force_moderation?: boolean; + is_pending_message?: boolean; + keep_channel_hidden?: boolean; + pending?: boolean; + pending_message_metadata?: Record; + skip_enrich_url?: boolean; + skip_push?: boolean; +}; + +export type UpdateMessageOptions = { + skip_enrich_url?: boolean; +}; + export type Mute = { created_at: string; target: UserResponse;