diff --git a/src/StreamChannel.ts b/src/StreamChannel.ts index 52aa66a..ef669f0 100644 --- a/src/StreamChannel.ts +++ b/src/StreamChannel.ts @@ -1,5 +1,5 @@ import { ChannelApi } from './gen/chat/ChannelApi'; -import { ChannelGetOrCreateRequest, QueryMembersRequest } from './gen/models'; +import { ChannelGetOrCreateRequest, QueryMembersPayload } from './gen/models'; import { OmitTypeId } from './types'; export class StreamChannel extends ChannelApi { @@ -27,7 +27,7 @@ export class StreamChannel extends ChannelApi { } }; - queryMembers(request?: { payload?: OmitTypeId }) { + queryMembers(request?: { payload?: OmitTypeId }) { return this.chatApi.queryMembers({ payload: { id: this.id, diff --git a/src/StreamClient.ts b/src/StreamClient.ts index e7612d2..430a2ff 100644 --- a/src/StreamClient.ts +++ b/src/StreamClient.ts @@ -4,7 +4,7 @@ import { StreamVideoClient } from './StreamVideoClient'; import crypto from 'crypto'; import { StreamChatClient } from './StreamChatClient'; import { CallTokenPayload, UserTokenPayload } from './types'; -import { QueryBannedUsersRequest, UserRequest } from './gen/models'; +import { QueryBannedUsersPayload, UserRequest } from './gen/models'; import { StreamModerationClient } from './StreamModerationClient'; export interface StreamClientOptions { @@ -67,7 +67,7 @@ export class StreamClient extends CommonApi { return this.updateUsers({ users: payload }); }; - queryBannedUsers = (request?: { payload?: QueryBannedUsersRequest }) => { + queryBannedUsers = (request?: { payload?: QueryBannedUsersPayload }) => { return this.chat.queryBannedUsers(request); }; diff --git a/src/gen/chat/ChannelApi.ts b/src/gen/chat/ChannelApi.ts index 5270302..4a655a9 100644 --- a/src/gen/chat/ChannelApi.ts +++ b/src/gen/chat/ChannelApi.ts @@ -27,6 +27,8 @@ import { UpdateChannelPartialResponse, UpdateChannelRequest, UpdateChannelResponse, + UpdateMemberPartialRequest, + UpdateMemberPartialResponse, } from '../models'; export class ChannelApi { @@ -167,6 +169,21 @@ export class ChannelApi { }); }; + updateMemberPartial = ( + request: UpdateMemberPartialRequest & { user_id: string }, + ): Promise> => { + if (!this.id) { + throw new Error( + `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`, + ); + } + return this.chatApi.updateMemberPartial({ + id: this.id, + type: this.type, + ...request, + }); + }; + sendMessage = ( request: SendMessageRequest, ): Promise> => { diff --git a/src/gen/chat/ChatApi.ts b/src/gen/chat/ChatApi.ts index 7d77e5a..50fa091 100644 --- a/src/gen/chat/ChatApi.ts +++ b/src/gen/chat/ChatApi.ts @@ -48,12 +48,12 @@ import { PollResponse, PollVoteResponse, PollVotesResponse, - QueryBannedUsersRequest, + QueryBannedUsersPayload, QueryBannedUsersResponse, QueryChannelsRequest, QueryChannelsResponse, - QueryMembersRequest, - QueryMessageFlagsRequest, + QueryMembersPayload, + QueryMessageFlagsPayload, QueryMessageFlagsResponse, QueryMessageHistoryRequest, QueryMessageHistoryResponse, @@ -66,7 +66,7 @@ import { QueryThreadsResponse, ReactionRemovalResponse, Response, - SearchRequest, + SearchPayload, SearchResponse, SendEventRequest, SendMessageRequest, @@ -92,6 +92,8 @@ import { UpdateChannelTypeResponse, UpdateCommandRequest, UpdateCommandResponse, + UpdateMemberPartialRequest, + UpdateMemberPartialResponse, UpdateMessagePartialRequest, UpdateMessagePartialResponse, UpdateMessageRequest, @@ -440,6 +442,38 @@ export class ChatApi extends BaseApi { return { ...response.body, metadata: response.metadata }; }; + updateMemberPartial = async ( + request: UpdateMemberPartialRequest & { + user_id: string; + type: string; + id: string; + }, + ): Promise> => { + const pathParams = { + user_id: request?.user_id, + type: request?.type, + id: request?.id, + }; + const body = { + unset: request?.unset, + set: request?.set, + }; + + const response = await this.sendRequest< + StreamResponse + >( + 'PATCH', + '/api/v2/chat/channels/{type}/{id}/member/{user_id}', + pathParams, + undefined, + body, + ); + + decoders.UpdateMemberPartialResponse?.(response.body); + + return { ...response.body, metadata: response.metadata }; + }; + sendMessage = async ( request: SendMessageRequest & { type: string; id: string }, ): Promise> => { @@ -900,7 +934,7 @@ export class ChatApi extends BaseApi { }; queryMembers = async (request?: { - payload?: QueryMembersRequest; + payload?: QueryMembersPayload; }): Promise> => { const queryParams = { payload: request?.payload, @@ -1329,7 +1363,7 @@ export class ChatApi extends BaseApi { }; queryMessageFlags = async (request?: { - payload?: QueryMessageFlagsRequest; + payload?: QueryMessageFlagsPayload; }): Promise> => { const queryParams = { payload: request?.payload, @@ -1690,7 +1724,7 @@ export class ChatApi extends BaseApi { }; queryBannedUsers = async (request?: { - payload?: QueryBannedUsersRequest; + payload?: QueryBannedUsersPayload; }): Promise> => { const queryParams = { payload: request?.payload, @@ -1706,7 +1740,7 @@ export class ChatApi extends BaseApi { }; search = async (request?: { - payload?: SearchRequest; + payload?: SearchPayload; }): Promise> => { const queryParams = { payload: request?.payload, diff --git a/src/gen/model-decoders/index.ts b/src/gen/model-decoders/index.ts index 1222646..a944289 100644 --- a/src/gen/model-decoders/index.ts +++ b/src/gen/model-decoders/index.ts @@ -375,7 +375,7 @@ decoders.ChannelStateResponse = (input?: Record) => { hide_messages_before: { type: 'DatetimeType', isSingle: true }, - pending_messages: { type: 'PendingMessage', isSingle: false }, + pending_messages: { type: 'PendingMessageResponse', isSingle: false }, read: { type: 'ReadStateResponse', isSingle: false }, @@ -400,7 +400,7 @@ decoders.ChannelStateResponseFields = (input?: Record) => { hide_messages_before: { type: 'DatetimeType', isSingle: true }, - pending_messages: { type: 'PendingMessage', isSingle: false }, + pending_messages: { type: 'PendingMessageResponse', isSingle: false }, read: { type: 'ReadStateResponse', isSingle: false }, @@ -445,6 +445,8 @@ decoders.ConfigResponse = (input?: Record) => { created_at: { type: 'DatetimeType', isSingle: true }, updated_at: { type: 'DatetimeType', isSingle: true }, + + velocity_filter_config: { type: 'VelocityFilterConfig', isSingle: true }, }; return decode(typeMappings, input); }; @@ -570,8 +572,6 @@ decoders.Flag2 = (input?: Record) => { updated_at: { type: 'DatetimeType', isSingle: true }, - moderation_payload: { type: 'ModerationPayload', isSingle: true }, - user: { type: 'UserObject', isSingle: true }, }; return decode(typeMappings, input); @@ -1057,13 +1057,6 @@ decoders.MessageWithChannelResponse = (input?: Record) => { return decode(typeMappings, input); }; -decoders.ModerationPayload = (input?: Record) => { - const typeMappings: TypeMapping = { - created_at: { type: 'DatetimeType', isSingle: true }, - }; - return decode(typeMappings, input); -}; - decoders.ModerationUsageStats = (input?: Record) => { const typeMappings: TypeMapping = { updated_at: { type: 'DatetimeType', isSingle: true }, @@ -1121,13 +1114,13 @@ decoders.OwnUser = (input?: Record) => { return decode(typeMappings, input); }; -decoders.PendingMessage = (input?: Record) => { +decoders.PendingMessageResponse = (input?: Record) => { const typeMappings: TypeMapping = { - channel: { type: 'Channel', isSingle: true }, + channel: { type: 'ChannelResponse', isSingle: true }, - message: { type: 'Message', isSingle: true }, + message: { type: 'MessageResponse', isSingle: true }, - user: { type: 'UserObject', isSingle: true }, + user: { type: 'UserResponse', isSingle: true }, }; return decode(typeMappings, input); }; @@ -1450,8 +1443,6 @@ decoders.ReviewQueueItem = (input?: Record) => { feeds_v2_reaction: { type: 'Reaction', isSingle: true }, message: { type: 'Message', isSingle: true }, - - moderation_payload: { type: 'ModerationPayload', isSingle: true }, }; return decode(typeMappings, input); }; @@ -1606,7 +1597,7 @@ decoders.ThreadStateResponse = (input?: Record) => { updated_at: { type: 'DatetimeType', isSingle: true }, - latest_replies: { type: 'Message', isSingle: false }, + latest_replies: { type: 'MessageResponse', isSingle: false }, deleted_at: { type: 'DatetimeType', isSingle: true }, @@ -1629,7 +1620,7 @@ decoders.TruncateChannelResponse = (input?: Record) => { const typeMappings: TypeMapping = { channel: { type: 'ChannelResponse', isSingle: true }, - message: { type: 'Message', isSingle: true }, + message: { type: 'MessageResponse', isSingle: true }, }; return decode(typeMappings, input); }; @@ -1725,6 +1716,13 @@ decoders.UpdateCommandResponse = (input?: Record) => { return decode(typeMappings, input); }; +decoders.UpdateMemberPartialResponse = (input?: Record) => { + const typeMappings: TypeMapping = { + channel_member: { type: 'ChannelMemberResponse', isSingle: true }, + }; + return decode(typeMappings, input); +}; + decoders.UpdateMessagePartialResponse = (input?: Record) => { const typeMappings: TypeMapping = { message: { type: 'Message', isSingle: true }, @@ -1860,6 +1858,20 @@ decoders.UserResponse = (input?: Record) => { return decode(typeMappings, input); }; +decoders.VelocityFilterConfig = (input?: Record) => { + const typeMappings: TypeMapping = { + rule: { type: 'VelocityFilterConfigRule', isSingle: false }, + }; + return decode(typeMappings, input); +}; + +decoders.VelocityFilterConfigRule = (input?: Record) => { + const typeMappings: TypeMapping = { + timeout: { type: 'DatetimeType', isSingle: true }, + }; + return decode(typeMappings, input); +}; + decoders.WSEvent = (input?: Record) => { const typeMappings: TypeMapping = { created_at: { type: 'DatetimeType', isSingle: true }, diff --git a/src/gen/models/index.ts b/src/gen/models/index.ts index 06cce03..2f42e7a 100644 --- a/src/gen/models/index.ts +++ b/src/gen/models/index.ts @@ -1089,6 +1089,8 @@ export interface ChannelMember { updated_at: Date; + custom: Record; + ban_expires?: Date; deleted_at?: Date; @@ -1121,6 +1123,8 @@ export interface ChannelMemberResponse { updated_at: Date; + custom: Record; + ban_expires?: Date; deleted_at?: Date; @@ -1225,7 +1229,7 @@ export interface ChannelStateResponse { watcher_count?: number; - pending_messages?: PendingMessage[]; + pending_messages?: PendingMessageResponse[]; read?: ReadStateResponse[]; @@ -1251,7 +1255,7 @@ export interface ChannelStateResponseFields { watcher_count?: number; - pending_messages?: PendingMessage[]; + pending_messages?: PendingMessageResponse[]; read?: ReadStateResponse[]; @@ -1500,6 +1504,8 @@ export interface ConfigResponse { bodyguard_config?: BodyguardConfig; go_og_le_vision_config?: GoogleVisionConfig; + + velocity_filter_config?: VelocityFilterConfig; } export interface Coordinates { @@ -1904,7 +1910,9 @@ export interface DeactivateUsersResponse { task_id: string; } -export interface DeleteActivityRequest {} +export interface DeleteActivityRequest { + hard_delete?: boolean; +} export interface DeleteCallRequest { hard?: boolean; @@ -2399,6 +2407,8 @@ export interface FullUserResponse { unread_channels: number; + unread_count: number; + unread_threads: number; updated_at: Date; @@ -3369,6 +3379,8 @@ export interface MessageFlagResponse { } export interface MessageHistoryEntryResponse { + is_deleted: boolean; + message_id: string; message_updated_at: Date; @@ -3641,8 +3653,6 @@ export interface ModerationActionConfig { } export interface ModerationPayload { - created_at?: Date; - images?: string[]; texts?: string[]; @@ -3870,14 +3880,14 @@ export interface PaginationParams { offset?: number; } -export interface PendingMessage { - channel?: Channel; +export interface PendingMessageResponse { + channel?: ChannelResponse; - message?: Message; + message?: MessageResponse; metadata?: Record; - user?: UserObject; + user?: UserResponse; } export interface Permission { @@ -4306,7 +4316,7 @@ export interface PushProviderResponse { xiaomi_package_name?: string; } -export interface QueryBannedUsersRequest { +export interface QueryBannedUsersPayload { filter_conditions: Record; exclude_expired_bans?: boolean; @@ -4440,7 +4450,7 @@ export interface QueryFeedModerationTemplatesResponse { templates: QueryFeedModerationTemplate[]; } -export interface QueryMembersRequest { +export interface QueryMembersPayload { type: string; filter_conditions: Record; @@ -4460,7 +4470,7 @@ export interface QueryMembersRequest { user?: UserRequest; } -export interface QueryMessageFlagsRequest { +export interface QueryMessageFlagsPayload { limit?: number; offset?: number; @@ -5092,7 +5102,7 @@ export interface ScreensharingSettingsResponse { target_resolution?: TargetResolution; } -export interface SearchRequest { +export interface SearchPayload { filter_conditions: Record; limit?: number; @@ -5368,7 +5378,7 @@ export interface StopTranscriptionResponse { export interface SubmitActionRequest { action_type: - | 'mark_safe' + | 'mark_reviewed' | 'delete_message' | 'delete_activity' | 'delete_reaction' @@ -5387,6 +5397,8 @@ export interface SubmitActionRequest { custom?: CustomActionRequest; + delete_activity?: DeleteActivityRequest; + delete_message?: DeleteMessageRequest; delete_reaction?: DeleteReactionRequest; @@ -5533,7 +5545,7 @@ export interface ThreadStateResponse { updated_at: Date; - latest_replies: Message[]; + latest_replies: MessageResponse[]; custom: Record; @@ -5692,7 +5704,7 @@ export interface TruncateChannelResponse { channel?: ChannelResponse; - message?: Message; + message?: MessageResponse; } export interface TypingIndicators { @@ -6197,6 +6209,18 @@ export interface UpdateExternalStorageResponse { type: 's3' | 'gcs' | 'abs'; } +export interface UpdateMemberPartialRequest { + unset?: string[]; + + set?: Record; +} + +export interface UpdateMemberPartialResponse { + duration: string; + + channel_member?: ChannelMemberResponse; +} + export interface UpdateMessagePartialRequest { skip_enrich_url?: boolean; @@ -6351,6 +6375,8 @@ export interface UpsertConfigRequest { bodyguard_config?: BodyguardConfig; go_og_le_vision_config?: GoogleVisionConfig; + + velocity_filter_config?: VelocityFilterConfig; } export interface UpsertConfigResponse { @@ -6546,6 +6572,8 @@ export interface UserSessionStats { max_freezes_duration_seconds: number; + min_event_ts: number; + packet_loss_fraction: number; publisher_packet_loss_fraction: number; @@ -6653,6 +6681,22 @@ export interface UserStats { rating?: number; } +export interface VelocityFilterConfig { + enabled?: boolean; + + rule?: VelocityFilterConfigRule[]; +} + +export interface VelocityFilterConfigRule { + action: 'flag' | 'shadow' | 'remove' | 'ban'; + + ip_ban?: boolean; + + shadow_ban?: boolean; + + timeout?: Date; +} + export interface VideoQuality { usage_type?: string; diff --git a/src/gen/moderation/ModerationApi.ts b/src/gen/moderation/ModerationApi.ts index 4641c69..b388b7a 100644 --- a/src/gen/moderation/ModerationApi.ts +++ b/src/gen/moderation/ModerationApi.ts @@ -104,6 +104,7 @@ export class ModerationApi extends BaseApi { block_list_config: request?.block_list_config, bodyguard_config: request?.bodyguard_config, go_og_le_vision_config: request?.go_og_le_vision_config, + velocity_filter_config: request?.velocity_filter_config, }; const response = await this.sendRequest< @@ -362,6 +363,7 @@ export class ModerationApi extends BaseApi { user_id: request?.user_id, ban: request?.ban, custom: request?.custom, + delete_activity: request?.delete_activity, delete_message: request?.delete_message, delete_reaction: request?.delete_reaction, delete_user: request?.delete_user,