Releases: GetStream/stream-node
Releases · GetStream/stream-node
v0.4.4
v0.4.3
v0.4.2
v0.4.1
v0.4.0
0.4.0 (2024-08-30)
⚠ BREAKING CHANGES
- use unified API spec, and go generator (#39)
This version marks a huge milestone in Stream's effort to speed up our development processes. The node-sdk is now fully autogenerated, which means that we'll be able to support new API specifications much faster. However, that change means that this version contains multiple breaking changes from the old syntax to the new one.
The above list contains all breaking changes. But if you run into any issue during the update, don't hesitate to open an issue on GitHub, or contact Stream's support.
All products
- Dates: instead of ISO date strings, the SDK will use
Date
objects both for requests (except forfilter_conditions
) and responses
const call = client.video.call('default', '123');
// New format - Date object instead of ISO date string
call.getOrCreate({data: {starts_at: new Date()}})
// For filter_conditions - no change
client.video.queryCalls({
filter_conditions: {
starts_at: { $gt: inNext30mins.toISOString() },
},
});
- All enums, except for
OwnCabaility
are replaced with string union types, so if you had something like this before:CreateDeviceRequestPushProviderEnum.FIREBASE
you need to change this to'firebase'
- Some models were renamed/deleted, if you're using JS these changes won't affect you, if you're using TS, you can rely on you IDE to help to make the necessary changes
Common (StreamClient
class)
- This version of the SDK now uses the new, moderation v2 endpoints (ban/unban, mute/unmute and flag methods), to enable access to these APIs, please contact support
// banUser is now ban
// Method moved to StreamModerationClient
// user_id renamed to banned_by_id
client.moderation.ban({
target_user_id: '<bad user id>',
banned_by_id: '<moderator id>',
reason: '<reason>',
});
// unbanUser is now unban
// Method moved to StreamModerationClient
// targetUserId renamed to target_user_id
// id renamed to created_by
client.moderation.unban({
target_user_id: '<bad user id>',
created_by: '<moderator id>',
});
// muteUser is now mute
// Method moved to StreamModerationClient
client.moderation.mute({
target_ids: ['user to mute id'],
user_id: 'user id',
})
// unmuteUser is now unmute
// Method moved to StreamModerationClient
client.moderation.unmute({
target_ids: ['user to unmute id'],
user_id: 'user id',
})
// flagMessage is removed, instead you can usethe following method:
client.moderation.flag({
entity_type: 'stream:chat:v1:message',
entity_id: messageId,
user_id: 'user-id',
// You can choose from a list of predefined reasons
reason: 'hate',
});
- Upserting users has a simplified syntax:
// New, simplified syntax
await client.upsertUsers([
{ name: 'John', id: 'john' },
{ name: 'Jack', id: 'jack' },
{ name: 'Jane', id: 'jane' },
{ name: 'Sara', id: 'sara' },
]);
- Some methods were renamed, and/or their parameters were slightly changed:
// user_id instead of userId
client.deleteDevice({ id: device.id, user_id: user.id })
// user_id instead of userId
client.listDevices({ user_id: user.id })
// wrap the request with push_provider
client.upsertPushProvider({ push_provider: pushProvider })
// banUser renamed
client.ban({ target_user_id: 'jack', user_id: 'sara' })
// unbanUser renamed to unban, request parameters have snake_case, instead of camelCase
client.unban({ target_user_id: 'john', created_by: 'jack', channel_cid: 'cats' })
// user_id instead of userId
client.exportUser({user_id: 'tom'})
// wrap the request with payload
client.queryBannedUsers({ payload: { filter_conditions: {} } }
// wrap the request with payload
client.queryUsers({ payload: { filter_conditions: { name: { $autocomplete: 'tom' } } } })
// sendCustomEventToUser renamed and signature is changed
client.chat.sendUserCustomEvent({ user_id: 'sophie', event: { type: 'my-custom-event' } })
// getAppSettings renamed
client.getApp()
// updateAppSettings renamed
client.updateApp( /* ... */ )
// getTaskStatus renamed
client.getTask({ id: 'task-id' })
// user_id instead of userId
client.getBlockedUsers({ user_id: user.id })
Video (StreamVideoClient
and StreamCall
classes)
- All video models used to have a
Video
prefix, which is now gone, so for example:VideoDeleteCallResponse
is changed toDeleteCallResponse
- Some methods were renamed, and/or their parameters were slightly changed:
StreamVideoClient
class
// queryCallStatistics renamed
client.video.queryCallStats( /* ... */ )
// updateCallType - call type name is part of the request object now
client.video.updateCallType({ name: callTypeName, grants: { user: userGrants, call_member: callMemberGrants } })
// listExternalStorages moved to StreamClient
client.listExternalStorage()
// createExternalStorage moved to StreamClient
client.createExternalStorage({ name: 'my-storage', bucket: 'my-bucket', storage_type: 's3' })
// deleteExternalStorage moved to StreamClient
client.deleteExternalStorage({ name: 'my-storage' })
// updateExternalStorage moved to StreamClient - storage name is part of the request object now
client.updateExternalStorage({ name: 'my-storage', bucket: 'new-bucket', storage_type: 's3' })
// checkExternalStorage moved to StreamClient
client.checkExternalStorage({ name: 'my-storage' })
StreamCall
class
// endCall renamed
call.end()
// members_limit instead of membersLimit
call.get({ members_limit: 20 })
// getSessionStatistics renamed
call.getCallStats({ session: '<session id>' })
// getCallStats moved to StreamVideoClient
client.video.queryCallStats({ filter_conditions: { call_cid: call.cid } })
// sendCustomEvent renamed
call.sendCallEvent({ custom: { 'render-animation': 'balloons' })
// pinVideo renamed
call.videoPin( /* ... */ )
// unpinVideo renamed
call.videoUnpin( /* ... */ )
Chat (StreamChatClient
and StreamChannel
classes)
name
andimage
of aChannel
need to be provided as custom data:
// Old format
const response = await channel.getOrCreate({
data: { created_by_id: user.id, name: 'Cats' },
});
// New format
const response = await channel.getOrCreate({
data: { created_by_id: user.id, custom: { name: 'Cats' } },
});
- Some methods were renamed, and/or their parameters were slightly changed:
StreamChatClient
class
// createBlockList moved to StreamClient
client.createBlockList({ name: 'fruits', words: ['apple', 'banana'] })
// listBlockLists moved to StreamClient
client.listBlockLists()
// getBlockList moved to StreamClient
client.getBlockList({ name: 'fruits' })
// updateBlockList moved to StreamClient, request object now contains block list name as well
client.updateBlockList({ name: 'fruits', words: ['apple', 'avocado', 'banana'] })
// deleteBlockList moved to StreamClient
client.deleteBlockList({ name: 'fruits' })
// updateChannelType - request object now contains the channel type name as well
client.chat.updateChannelType({ name: channelType, automod: 'simple', automod_behavior: 'block', max_message_length: 20000 })
// searchMessages renamed, request object should be wrapped with payload
client.chat.search({ payload: {
filter_conditions: { members: { $in: ['user if'] } },
message_filter_conditions: { text: { $autocomplete: 'check' } },
}
});
// getExportStatus renamed
client.chat.getExportChannelsStatus({ id: 'task-id' })
// updateCommand - request object now contains the command name as well
client.chat.updateCommand({ name: commandName, description: 'Updated descrpition' })
StreamChannel
class
// hardDelete renamed to hard_delete
channel.delete({ hard_delete: true })
// updatePartia renamed
channel.updateChannelPartial({ set: { cooldown: 100 }, unset: [] })
// queryMembers - request object should be wrapped with payload
channel.queryMembers({ payload: { filter_conditions: { name: { $autocomplete: '2' } } } })
// mute was moved to StreamChatClient
client.chat.muteChannel({ user_id: 'user-id', channel_cids: [channel.cid] })
// unmute was moved to StreamChatClient
client.chat.unmuteChannel({ user_id: 'user-id', channel_cids: [channel.cid] })
// deleteMesage moved to StreamChatClient, deleted_by instead of deletedBy
client.chat.deleteMessage({ id: messageId, deleted_by: 'user-id' })
// updateMessage moved to StreamChatClient - the request object now contains the message id as well
client.chat.updateMessage({id: messageId, message: { text: 'Hi 👋' }})
// updateMessagePartial moved to StreamChatClient - the request object now contains the message id as well
client.chat.updateMessagePartial({id: messageId, set: { text: 'check this out: https://getstream.io/' } })
// getMessage moved to StreamChatClient, show_deleted_message instead of showDeletedMessage
client.chat.getMessage({ id: messageId, show_deleted_message: true })
// translateMessage moved to StreamChatClient, message id is now part of the request object
client.chat.translateMessage({ id: messageId, language: 'hu' })
// getMessagesAround renamed and moved to StreamChatClient, request object now uses snake_case instead of camelCase
client.chat.getReplies({ id_around: messageId })
// getOpenGraphData renamed and moved to StreamChatClient
client.getOG({ url: 'https://getstream.io/' })
// sendMessageReaction renamed and moved to StreamChatClient, request object now also includes message id
client.chat.sendReaction({ id: messageId, reaction: { type: 'like', user_id: user.id } })
// deleteMessageReaction renamed and moved to StreamChatClient, request object now also includes message id, request now uses snake case
client.chat.deleteReaction({ id: messageId, type: 'like', user_id: user.id })
// getMessageReactions renamed and moved to StreamChatClient, request object now also includes message i...