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.
Please check the installation guide for TS SDK here - TypeScript.
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:
import { MessageRepository } from '@amityco/js-sdk';TypeScript SDK:
import { MessageRepository } from '@amityco/ts-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.channelIdremoved.channelTypenow 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.joinChannelandleaveChannel: Simplified method signature fromjoinChannel({ channelId: '<channelId>'})tojoinChannel('<channelId>')- Join/Leave Channel.updateChannel: Updated to a more concise signature - Update Channel.banMembers→Moderation.banMembers: Moved underModerationwith an updated method signature - Ban/Unban a List of Channel Members.unbanMembers→Moderation.unbanMembers: Now underModerationwith changes in parameters - Ban/Unban a List of Channel Members.
Removed Methods
muteMembersunmuteMembersremoveRateLimitsetRateLimit
MessageRepository Changes
addReaction&removeReaction: Moved toReactionRepositorywith updated functionality - Add / Remove Reaction.flag,unflag,isFlaggedByMe: Replaced withflagMessage,unflagMessage,isMessageFlaggedByMe- Flag/Unflag a Message.createTextMessage,createImageMessage,createFileMessageconsolidated intocreateMessagefor unified message creation - Send a Message.updateMessagetoeditMessage: Signature updated for direct editing.deleteMessagetosoftDeleteMessage&queryMessagestogetMessages: Updated for clarity and functionality.
Removed Methods
MessageTools
CommunityRepository Changes
Membership and moderation-related methods have been restructured under
MembershipandModerationrespectively, with updated signatures for adding, banning, and removing members and roles - Community Moderation.
Removed Methods
categoriesForIds
FileRepository and LiveStreamPlayer Changes
Introduction of
uploadFileanduploadVideomethods replacingcreateFileandcreateVideoinFileRepository. - Files, Images, and Videos.LiveStreamPlayerremains unchanged with thegetPlayermethod - View & Play Live Stream.
PostRepository Changes
Transition from specific post creation methods to a unified
createPostmethod, 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.deletePostinstead - 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
Was this helpful?