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 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.

  • queryChannelsgetChannels: 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.

  • banMembersModeration.banMembers: Moved under Moderation with an updated method signature - Ban/Unban a List of Channel Members.

  • unbanMembersModeration.unbanMembers: Now under Moderation with changes in parameters - Ban/Unban a List of Channel Members.

Removed Methods

  • muteMembers

  • unmuteMembers

  • removeRateLimit

  • setRateLimit


MessageRepository Changes

  • 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.

Removed Methods

  • MessageTools


CommunityRepository Changes

  • 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.

Removed Methods

  • categoriesForIds


FileRepository and LiveStreamPlayer Changes


PostRepository Changes

  • Transition from specific post creation methods to a unified createPost method, accommodating different types of content through parameters - Create Post.

  • updatePosteditPost: Aligned with new content structuring and tagging - Edit Post.

Removed Methods

  • hardDeletePost- please use PostRepository.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>') to Relationship.getFollowers({ userId: '<userId>', status: '<status>' }).

  • getFollowings → Relationship.getFollowings

    • Updated from getFollowings('<userId>') to Relationship.getFollowings({ userId: '<userId>' }).

Last updated