From a4b19e1ab1f9e1dcbab6fc2f984627a674695049 Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 13:33:43 +0200 Subject: [PATCH 1/6] fix: fix channel.membership type --- src/channel_state.ts | 3 +-- src/types.ts | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/channel_state.ts b/src/channel_state.ts index 34023b9d1..47d6de817 100644 --- a/src/channel_state.ts +++ b/src/channel_state.ts @@ -1,7 +1,6 @@ import { Channel } from './channel'; import { ChannelMemberResponse, - ChannelMembership, FormatMessageResponse, Event, ExtendableGenerics, @@ -42,7 +41,7 @@ export class ChannelState>; members: Record>; unreadCount: number; - membership: ChannelMembership; + membership: ChannelMemberResponse; last_message_at: Date | null; /** * Flag which indicates if channel state contain latest/recent messages or no. diff --git a/src/types.ts b/src/types.ts index bd124c54d..dcf35cbd4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -313,7 +313,7 @@ export type ChannelAPIResponse[]; pinned_messages: MessageResponse[]; hidden?: boolean; - membership?: ChannelMembership | null; + membership?: ChannelMemberResponse | null; pending_messages?: PendingMessageResponse[]; read?: ReadResponse[]; threads?: ThreadResponse[]; @@ -331,6 +331,7 @@ export type ChannelMemberAPIResponse = { + ban_expires?: string; banned?: boolean; channel_role?: Role; created_at?: string; @@ -1667,9 +1668,9 @@ export type UserFilters['name']>; notifications_muted?: | RequireOnlyOne<{ - $eq?: PrimitiveFilter['notifications_muted']>; - }> - | boolean; + $eq?: PrimitiveFilter['notifications_muted']>; + }> + | boolean; teams?: | RequireOnlyOne<{ $contains?: PrimitiveFilter; @@ -2042,18 +2043,12 @@ export type ChannelData< name?: string; }; -export type ChannelMembership = { - banned?: boolean; - channel_role?: Role; - created_at?: string; - is_moderator?: boolean; - notifications_muted?: boolean; - role?: string; - shadow_banned?: boolean; - status?: string; - updated_at?: string; - user?: UserResponse; -}; +/** + * @deprecated Use ChannelMemberResponse instead + */ +export type ChannelMembership< + StreamChatGenerics extends ExtendableGenerics = DefaultGenerics +> = ChannelMemberResponse; export type ChannelMute = { user: UserResponse; From 5796eb3cc697fd3b921d12d627648ec1f12d4b81 Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 13:44:07 +0200 Subject: [PATCH 2/6] fix: unrelated ts fixes --- test/typescript/unit-test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/typescript/unit-test.ts b/test/typescript/unit-test.ts index bd2d52f27..cb15fce26 100644 --- a/test/typescript/unit-test.ts +++ b/test/typescript/unit-test.ts @@ -40,6 +40,8 @@ type EventType = UR; type MessageType = UR; type ReactionType = UR; type CommandType = string & {}; +type PollType = UR; +type PollOptionType = UR; type StreamTypes = { attachmentType: AttachmentType; @@ -49,6 +51,8 @@ type StreamTypes = { messageType: MessageType; reactionType: ReactionType; userType: UserType; + pollType: PollType; + pollOptionType: PollOptionType; }; let voidReturn: void | { unsubscribe: () => void }; @@ -67,6 +71,8 @@ const clientWithoutSecret: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }> = new StreamChat<{ attachmentType: {}; channelType: ChannelType; @@ -75,6 +81,8 @@ const clientWithoutSecret: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }>(apiKey, { timeout: 3000, logger: (logLevel: string, msg: string, extraData?: Record) => {}, @@ -90,6 +98,8 @@ const singletonClient1: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }> = StreamChat.getInstance<{ attachmentType: {}; channelType: ChannelType; @@ -98,6 +108,8 @@ const singletonClient1: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }>(apiKey); const singletonClient2: StreamChat<{ @@ -108,6 +120,8 @@ const singletonClient2: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }> = StreamChat.getInstance<{ attachmentType: {}; channelType: ChannelType; @@ -116,6 +130,8 @@ const singletonClient2: StreamChat<{ messageType: {}; reactionType: {}; userType: UserType; + pollType: {}; + pollOptionType: {}; }>(apiKey, '', {}); const devToken: string = client.devToken('joshua'); From ceb91b630b694b20c4fd2f5723b6d03d00ba22d9 Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 13:50:17 +0200 Subject: [PATCH 3/6] fix: more unrelated type fixes --- test/typescript/index.js | 96 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/test/typescript/index.js b/test/typescript/index.js index d35c85fba..7cdd9c6b2 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -11,7 +11,7 @@ const executables = [ f: rg.acceptInvite, imports: ['Channel', 'Unpacked'], type: - "Unpacked['acceptInvite']>>", + "Unpacked['acceptInvite']>>", }, { f: rg.addDevice, @@ -22,13 +22,13 @@ const executables = [ f: rg.addMembers, imports: ['Channel', 'Unpacked'], type: - "Unpacked['addMembers']>>", + "Unpacked['addMembers']>>", }, { f: rg.addModerators, imports: ['Channel', 'Unpacked'], type: - "Unpacked['addModerators']>>", + "Unpacked['addModerators']>>", }, { f: rg.banUsers, @@ -60,13 +60,13 @@ const executables = [ f: rg.create, imports: ['Channel', 'Unpacked'], type: - "Unpacked['create']>>", + "Unpacked['create']>>", }, { f: rg.createBlockList, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['createBlockList']>>", + "Unpacked['createBlockList']>>", }, // createChannelType has a limit. So only run this when needed. // { @@ -78,7 +78,7 @@ const executables = [ f: rg.createCommand, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['createCommand']>>", + "Unpacked['createCommand']>>", }, { f: rg.createPermission, @@ -94,13 +94,13 @@ const executables = [ f: rg.deleteBlockList, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['deleteBlockList']>>", + "Unpacked['deleteBlockList']>>", }, { f: rg.deleteChannel, imports: ['Channel', 'Unpacked'], type: - "Unpacked['delete']>>", + "Unpacked['delete']>>", }, // TODO: Fix the error which results from deleteChannelType api call: // `deleteChannelType failed with error: { Error: StreamChat error code 16: DeleteChannelType failed with error: "bc0b09df-2cfd-4e80-93e7-1f0091e6a435 is not a defined channel type"` @@ -114,19 +114,19 @@ const executables = [ f: rg.deleteCommand, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['deleteCommand']>>", + "Unpacked['deleteCommand']>>", }, { f: rg.deleteFile, imports: ['Channel', 'Unpacked'], type: - "Unpacked['deleteFile']>>", + "Unpacked['deleteFile']>>", }, { f: rg.deleteImage, imports: ['Channel', 'Unpacked'], type: - "Unpacked['deleteImage']>>", + "Unpacked['deleteImage']>>", }, { f: rg.deleteMessage, @@ -142,7 +142,7 @@ const executables = [ f: rg.deleteReaction, imports: ['Channel', 'Unpacked'], type: - "Unpacked['deleteReaction']>>", + "Unpacked['deleteReaction']>>", }, { f: rg.deleteUser, @@ -153,7 +153,7 @@ const executables = [ f: rg.demoteModerators, imports: ['Channel', 'Unpacked'], type: - "Unpacked['demoteModerators']>>", + "Unpacked['demoteModerators']>>", }, // { // f: rg.disconnect, @@ -169,13 +169,13 @@ const executables = [ f: rg.flagMessage, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['flagMessage']>>", + "Unpacked['flagMessage']>>", }, { f: rg.flagUser, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['flagUser']>>", + "Unpacked['flagUser']>>", }, { f: rg.getAppSettings, @@ -196,13 +196,13 @@ const executables = [ f: rg.getCommand, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['getCommand']>>", + "Unpacked['getCommand']>>", }, { f: rg.getConfig, imports: ['Channel', 'Unpacked'], type: - "Unpacked['getConfig']>>", + "Unpacked['getConfig']>>", }, { f: rg.getDevices, @@ -218,13 +218,13 @@ const executables = [ f: rg.getMessagesById, imports: ['Channel', 'Unpacked'], type: - "Unpacked['getMessagesById']>>", + "Unpacked['getMessagesById']>>", }, { f: rg.getMessageWithReply, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['getMessage']>>", + "Unpacked['getMessage']>>", }, { f: rg.getPermission, @@ -235,37 +235,37 @@ const executables = [ f: rg.getReactions, imports: ['Channel', 'Unpacked'], type: - "Unpacked['getReactions']>>", + "Unpacked['getReactions']>>", }, { f: rg.getReplies, imports: ['Channel', 'Unpacked'], type: - "Unpacked['getReplies']>>", + "Unpacked['getReplies']>>", }, { f: rg.hide, imports: ['Channel', 'Unpacked'], type: - "Unpacked['hide']>>", + "Unpacked['hide']>>", }, { f: rg.inviteMembers, imports: ['Channel', 'Unpacked'], type: - "Unpacked['inviteMembers']>>", + "Unpacked['inviteMembers']>>", }, { f: rg.keystroke, imports: ['Channel', 'Unpacked'], type: - "Unpacked['keystroke']>>", + "Unpacked['keystroke']>>", }, { f: rg.lastMessage, imports: ['Channel', 'FormatMessageResponse', 'Unpacked'], type: - "Omit, 'created_at' | 'updated_at'> & { created_at?: string; updated_at?: string } | undefined", + "Omit, 'created_at' | 'updated_at'> & { created_at?: string; updated_at?: string } | undefined", }, { f: rg.listBlockLists, @@ -281,7 +281,7 @@ const executables = [ f: rg.listCommands, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['listCommands']>>", + "Unpacked['listCommands']>>", }, { f: rg.listPermissions, @@ -297,19 +297,19 @@ const executables = [ f: rg.markRead, imports: ['Channel', 'Unpacked'], type: - "Unpacked['markRead']>>", + "Unpacked['markRead']>>", }, { f: rg.mute, imports: ['Channel', 'Unpacked'], type: - "Unpacked['mute']>>", + "Unpacked['mute']>>", }, { f: rg.muteStatus, imports: ['Channel', 'Unpacked'], type: - "Unpacked['muteStatus']>>", + "Unpacked['muteStatus']>>", }, { f: rg.muteUser, @@ -332,7 +332,7 @@ const executables = [ f: rg.query, imports: ['Channel', 'Unpacked'], type: - "Unpacked['query']>>", + "Unpacked['query']>>", }, // TODO: Add this back in when queryBannedUsers is deployed to all shards for testing // { @@ -345,7 +345,7 @@ const executables = [ f: rg.queryMembers, imports: ['Channel', 'Unpacked'], type: - "Unpacked['queryMembers']>>", + "Unpacked['queryMembers']>>", }, { f: rg.queryUsers, @@ -368,7 +368,7 @@ const executables = [ f: rg.removeMembers, imports: ['Channel', 'Unpacked'], type: - "Unpacked['removeMembers']>>", + "Unpacked['removeMembers']>>", }, { f: rg.removeShadowBan, @@ -385,13 +385,13 @@ const executables = [ f: rg.sendFile, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendFile']>>", + "Unpacked['sendFile']>>", }, { f: rg.sendImage, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendImage']>>", + "Unpacked['sendImage']>>", }, { f: rg.sendMessage, @@ -403,13 +403,13 @@ const executables = [ f: rg.sendMessageReadEvent, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendEvent']>>", + "Unpacked['sendEvent']>>", }, { f: rg.sendReaction, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendReaction']>>", + "Unpacked['sendReaction']>>", }, { f: rg.setGuestUser, @@ -425,31 +425,31 @@ const executables = [ f: rg.show, imports: ['Channel', 'Unpacked'], type: - "Unpacked['show']>>", + "Unpacked['show']>>", }, { f: rg.stopTyping, imports: ['Channel', 'Unpacked'], type: - "Unpacked['stopTyping']>>", + "Unpacked['stopTyping']>>", }, { f: rg.stopWatching, imports: ['Channel', 'Unpacked'], type: - "Unpacked['stopWatching']>>", + "Unpacked['stopWatching']>>", }, { f: rg.sync, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['sync']>>", + "Unpacked['sync']>>", }, { f: rg.syncTeam, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['sync']>>", + "Unpacked['sync']>>", }, // Need translation on the account to run this test // { @@ -462,7 +462,7 @@ const executables = [ f: rg.truncateChannel, imports: ['Channel', 'Unpacked'], type: - "Unpacked['truncate']>>", + "Unpacked['truncate']>>", }, { f: rg.unbanUsers, @@ -473,7 +473,7 @@ const executables = [ f: rg.unmute, imports: ['Channel', 'Unpacked'], type: - "Unpacked['unmute']>>", + "Unpacked['unmute']>>", }, { f: rg.unmuteUser, @@ -489,19 +489,19 @@ const executables = [ f: rg.updateBlockList, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['updateBlockList']>>", + "Unpacked['updateBlockList']>>", }, { f: rg.updateChannel, imports: ['Channel', 'Unpacked'], type: - "Unpacked['update']>>", + "Unpacked['update']>>", }, { f: rg.updateChannelFromOriginal, imports: ['Channel', 'Unpacked'], type: - "Unpacked['update']>>", + "Unpacked['update']>>", }, { f: rg.updateChannelType, @@ -512,7 +512,7 @@ const executables = [ f: rg.updateCommand, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['updateCommand']>>", + "Unpacked['updateCommand']>>", }, { f: rg.updateMessage, @@ -541,7 +541,7 @@ const executables = [ f: rg.watch, imports: ['Channel', 'Unpacked'], type: - "Unpacked['watch']>>", + "Unpacked['watch']>>", }, // Currently roles do not return From d1346b2a6b762c8ede84f5c0f6da17b9da06db99 Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 13:56:25 +0200 Subject: [PATCH 4/6] fix: even more type fixes --- test/typescript/index.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/typescript/index.js b/test/typescript/index.js index 7cdd9c6b2..a5a5b8eaf 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -22,13 +22,13 @@ const executables = [ f: rg.addMembers, imports: ['Channel', 'Unpacked'], type: - "Unpacked['addMembers']>>", + "Unpacked['addMembers']>>", }, { f: rg.addModerators, imports: ['Channel', 'Unpacked'], type: - "Unpacked['addModerators']>>", + "Unpacked['addModerators']>>", }, { f: rg.banUsers, @@ -60,13 +60,13 @@ const executables = [ f: rg.create, imports: ['Channel', 'Unpacked'], type: - "Unpacked['create']>>", + "Unpacked['create']>>", }, { f: rg.createBlockList, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['createBlockList']>>", + "Unpacked['createBlockList']>>", }, // createChannelType has a limit. So only run this when needed. // { @@ -320,13 +320,13 @@ const executables = [ f: rg.partialUpdateUser, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['partialUpdateUser']>>", + "Unpacked['partialUpdateUser']>>", }, { f: rg.partialUpdateUsers, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['partialUpdateUsers']>>", + "Unpacked['partialUpdateUsers']>>", }, { f: rg.query, @@ -351,7 +351,7 @@ const executables = [ f: rg.queryUsers, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['queryUsers']>>", + "Unpacked['queryUsers']>>", }, { f: rg.reactivateUser, @@ -362,7 +362,7 @@ const executables = [ f: rg.rejectInvite, imports: ['Channel', 'Unpacked'], type: - "Unpacked['rejectInvite']>>", + "Unpacked['rejectInvite']>>", }, { f: rg.removeMembers, @@ -379,7 +379,7 @@ const executables = [ f: rg.sendAction, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendAction']>>", + "Unpacked['sendAction']>>", }, { f: rg.sendFile, @@ -397,7 +397,7 @@ const executables = [ f: rg.sendMessage, imports: ['Channel', 'Unpacked'], type: - "Unpacked['sendMessage']>>", + "Unpacked['sendMessage']>>", }, { f: rg.sendMessageReadEvent, @@ -518,7 +518,7 @@ const executables = [ f: rg.updateMessage, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['updateMessage']>>", + "Unpacked['updateMessage']>>", }, { f: rg.updatePermission, @@ -529,13 +529,13 @@ const executables = [ f: rg.upsertUsers, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['upsertUsers']>>", + "Unpacked['upsertUsers']>>", }, { f: rg.upsertUser, imports: ['StreamChat', 'Unpacked'], type: - "Unpacked['upsertUser']>>", + "Unpacked['upsertUser']>>", }, { f: rg.watch, From 311858f334d32e476c070bcc1a6007eec3a36b5d Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 14:12:52 +0200 Subject: [PATCH 5/6] fix: even more unrelated types --- src/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types.ts b/src/types.ts index dcf35cbd4..d115efd10 100644 --- a/src/types.ts +++ b/src/types.ts @@ -143,6 +143,7 @@ export type AppSettingsAPIResponse; + poll_enabled?: boolean; push_notifications?: { offline_only: boolean; version: string; @@ -820,6 +821,8 @@ export type UserResponse[]; + invisible?: boolean; language?: TranslationLanguages | ''; last_active?: string; online?: boolean; From e791562c2bcc0be88c2d5a2a4b76d9f49acf4eab Mon Sep 17 00:00:00 2001 From: Matvei Andrienko Date: Thu, 16 May 2024 14:40:12 +0200 Subject: [PATCH 6/6] fix: don't touch UserResponse at all, too scary --- src/types.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index d115efd10..d3f35c6c2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -821,8 +821,6 @@ export type UserResponse[]; - invisible?: boolean; language?: TranslationLanguages | ''; last_active?: string; online?: boolean;