JS SDK to TS SDK Migration Guide
Migration Guide from JavaScript SDK to TypeScript SDK
Welcome to the migration guide designed to assist you in transitioning from our JavaScript SDK to the TypeScript SDK. This migration involves not only method name changes but also a shift towards a more type-safe and structured approach, leveraging TypeScript's capabilities for better code quality and maintainability. For each method or property that has been changed, ensure to review the new signature or structure carefully and adjust your code accordingly. The aim is to take advantage of TypeScript's features to enhance your application's robustness and developer experience.
Remember to test thoroughly after making these changes to ensure that your application continues to function as expected. If you encounter any issues or need further assistance, our support team is here to help.
Importing the SDK
When migrating from the JavaScript SDK to the TypeScript SDK, update the import statements in your project to reflect the new package name.
JavaScript SDK:
TypeScript SDK:
This change is crucial for accessing the updated SDK functionalities and types provided by the TypeScript version. Ensure all import statements in your project are updated accordingly.
ChannelRepository Changes
createChannel
: Enhanced withavatarFileId
,displayName
,tags
, andmetadata
.channelId
removed.channelType
now strictly'broadcast'
,'conversation'
,'community'
, or'live'
- Create Channel.channelType
: Now uses string literals'broadcast'
,'conversation'
,'community'
,'live'
instead ofChannelType
.queryChannels
→getChannels
: Method name updated; parameters for filtering and sorting channels have changed - Get Channels.joinChannel
andleaveChannel
: Simplified method signature fromjoinChannel({ channelId: '<channelId>'})
tojoinChannel('<channelId>')
- Join/Leave Channel.updateChannel
: Updated to a more concise signature - Update Channel.banMembers
→Moderation.banMembers
: Moved underModeration
with an updated method signature - Ban/Unban a List of Channel Members.unbanMembers
→Moderation.unbanMembers
: Now underModeration
with changes in parameters - Ban/Unban a List of Channel Members.
Removed Methods
muteMembers
unmuteMembers
removeRateLimit
setRateLimit
MessageRepository Changes
addReaction
&removeReaction
: Moved toReactionRepository
with updated functionality - Add / Remove Reaction.flag
,unflag
,isFlaggedByMe
: Replaced withflagMessage
,unflagMessage
,isMessageFlaggedByMe
- Flag/Unflag a Message.createTextMessage
,createImageMessage
,createFileMessage
consolidated intocreateMessage
for unified message creation - Send a Message.updateMessage
toeditMessage
: Signature updated for direct editing.deleteMessage
tosoftDeleteMessage
&queryMessages
togetMessages
: Updated for clarity and functionality.
Removed Methods
MessageTools
CommunityRepository Changes
Membership and moderation-related methods have been restructured under
Membership
andModeration
respectively, with updated signatures for adding, banning, and removing members and roles - Community Moderation.
Removed Methods
categoriesForIds
FileRepository and LiveStreamPlayer Changes
Introduction of
uploadFile
anduploadVideo
methods replacingcreateFile
andcreateVideo
inFileRepository
. - Files, Images, and Videos.LiveStreamPlayer
remains unchanged with thegetPlayer
method - View & Play Live Stream.
PostRepository Changes
Transition from specific post creation methods to a unified
createPost
method, accommodating different types of content through parameters - Create Post.updatePost
→editPost
: Aligned with new content structuring and tagging - Edit Post.
Removed Methods
hardDeletePost
- please usePostRepository.deletePost
instead - Delete Post.
UserRepository Changes
The UserRepository has seen several method updates to align with the new TypeScript SDK, specifically transitioning to the Relationship
namespace for managing user relationships. These updates facilitate a more structured approach to handling followers and followings within applications - Follow/Unfollow.
getFollowInfo → Relationship.getFollowInfo
followAccept → Relationship.acceptMyFollower
follow → Relationship.follow
followDecline → Relationship.declineMyFollower
getFollowers → Relationship.getFollowers
Changed from
getFollowers('<userId>', '<status>')
toRelationship.getFollowers({ userId: '<userId>', status: '<status>' })
.
getFollowings → Relationship.getFollowings
Updated from
getFollowings('<userId>')
toRelationship.getFollowings({ userId: '<userId>' })
.
Last updated