JS SDK to TS SDK Migration Guide
Last updated
Last updated
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.
Please check the installation guide for TS SDK here - .
When migrating from the JavaScript SDK to the TypeScript SDK, update the import statements in your project to reflect the new package name.
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.
createChannel
: Enhanced with avatarFileId
, displayName
, tags
, and metadata
. channelId
removed. channelType
now strictly 'broadcast'
, 'conversation'
, 'community'
, or 'live'
- Create Channel.
channelType
: Now uses string literals 'broadcast'
, 'conversation'
, 'community'
, 'live'
instead of ChannelType
.
queryChannels
→ getChannels
: Method name updated; parameters for filtering and sorting channels have changed - Get Channels.
joinChannel
and leaveChannel
: Simplified method signature from joinChannel({ channelId: '<channelId>'})
to joinChannel('<channelId>')
- Join/Leave Channel.
updateChannel
: Updated to a more concise signature - Update Channel.
banMembers
→ Moderation.banMembers
: Moved under Moderation
with an updated method signature - Ban/Unban a List of Channel Members.
unbanMembers
→ Moderation.unbanMembers
: Now under Moderation
with changes in parameters - Ban/Unban a List of Channel Members.
muteMembers
unmuteMembers
removeRateLimit
setRateLimit
addReaction
& removeReaction
: Moved to ReactionRepository
with updated functionality - Add / Remove Reaction.
flag
, unflag
, isFlaggedByMe
: Replaced with flagMessage
, unflagMessage
, isMessageFlaggedByMe
- Flag/Unflag a Message.
createTextMessage
, createImageMessage
, createFileMessage
consolidated into createMessage
for unified message creation - Send a Message.
updateMessage
to editMessage
: Signature updated for direct editing.
deleteMessage
to softDeleteMessage
& queryMessages
to getMessages
: Updated for clarity and functionality.
MessageTools
Membership and moderation-related methods have been restructured under Membership
and Moderation
respectively, with updated signatures for adding, banning, and removing members and roles - Community Moderation.
categoriesForIds
Introduction of uploadFile
and uploadVideo
methods replacing createFile
and createVideo
in FileRepository
. - Files, Images, and Videos.
LiveStreamPlayer
remains unchanged with the getPlayer
method - View & Play Live Stream.
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.
hardDeletePost
- please use PostRepository.deletePost
instead - Delete Post.
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>')
to Relationship.getFollowers({ userId: '<userId>', status: '<status>' })
.
getFollowings → Relationship.getFollowings
Updated from getFollowings('<userId>')
to Relationship.getFollowings({ userId: '<userId>' })
.