@ermis-network/ermis-chat-sdk 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -222,6 +222,7 @@ type ChannelResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGener
222
222
  member_capabilities?: string[];
223
223
  is_pinned?: boolean;
224
224
  topics_enabled?: boolean;
225
+ parent_cid?: string;
225
226
  is_closed_topic?: boolean;
226
227
  };
227
228
  type QueryChannelsAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
@@ -401,6 +402,7 @@ type Event$1<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = E
401
402
  message?: MessageResponse<ErmisChatGenerics>;
402
403
  online?: boolean;
403
404
  parent_id?: string;
405
+ parent_cid?: string;
404
406
  reaction?: ReactionResponse<ErmisChatGenerics>;
405
407
  received_at?: string | Date;
406
408
  unread_messages?: number;
@@ -428,6 +430,16 @@ type ChannelFilters = {
428
430
  parent_id?: string;
429
431
  include_parent?: boolean;
430
432
  };
433
+ type CreateTopicData = {
434
+ name: string;
435
+ image?: string;
436
+ [key: string]: any;
437
+ };
438
+ type EditTopicData = {
439
+ name?: string;
440
+ image?: string;
441
+ description?: string;
442
+ };
431
443
  type ChannelSort = {
432
444
  field: string;
433
445
  direction: -1 | 1;
@@ -863,6 +875,8 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
863
875
  }): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
864
876
  pinMessage(messageID: string): Promise<unknown>;
865
877
  unpinMessage(messageID: string): Promise<unknown>;
878
+ pin(): Promise<APIResponse>;
879
+ unpin(): Promise<APIResponse>;
866
880
  editMessage(oldMessageID: string, message: EditMessage): Promise<unknown>;
867
881
  sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse<ErmisChatGenerics>): Promise<SendFileAPIResponse>;
868
882
  /**
@@ -961,7 +975,7 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
961
975
  }[];
962
976
  getCapabilitiesMember(): unknown;
963
977
  create: () => Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
964
- createTopic(data: any): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
978
+ createTopic(data: CreateTopicData): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
965
979
  query(options: ChannelQueryOptions, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
966
980
  createDirectChannel(messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
967
981
  queryMessagesLessThanId(message_id: string, limit?: number): Promise<MessageResponse<ErmisChatGenerics>[]>;
@@ -978,7 +992,7 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
978
992
  disableTopics(): Promise<unknown>;
979
993
  closeTopic(topicCID: string): Promise<unknown>;
980
994
  reopenTopic(topicCID: string): Promise<unknown>;
981
- editTopic(topicCID: string, data: any): Promise<any>;
995
+ editTopic(topicCID: string, data: EditTopicData): Promise<any>;
982
996
  on(eventType: EventTypes, callback: EventHandler<ErmisChatGenerics>): {
983
997
  unsubscribe: () => void;
984
998
  };
@@ -1132,8 +1146,8 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1132
1146
  * @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
1133
1147
  * @returns A promise resolving to the API connection response once authenticated.
1134
1148
  */
1135
- connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1136
- setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1149
+ connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1150
+ setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1137
1151
  _setToken: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null) => Promise<void>;
1138
1152
  _setUser(user: UserResponse<ErmisChatGenerics>): void;
1139
1153
  closeConnection: (timeout?: number) => Promise<void>;
@@ -1218,10 +1232,17 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1218
1232
  searchUsers(page: number, page_size: number, name?: string): Promise<UsersResponse>;
1219
1233
  queryContacts(): Promise<ContactResult>;
1220
1234
  _updateProjectID(project_id: string): void;
1221
- uploadFile(file: File): Promise<{
1235
+ /**
1236
+ * Uploads a new avatar image for the current user.
1237
+ * The user's avatar URL is automatically updated in both the client and the local state.
1238
+ *
1239
+ * @param file - The image file to upload.
1240
+ * @returns The response containing the new avatar URL.
1241
+ */
1242
+ uploadAvatar(file: File): Promise<{
1222
1243
  avatar: string;
1223
1244
  }>;
1224
- updateProfile(name: string, about_me: string): Promise<UserResponse<ErmisChatGenerics>>;
1245
+ updateProfile(updates: Partial<UserResponse<ErmisChatGenerics>>): Promise<UserResponse<ErmisChatGenerics>>;
1225
1246
  /**
1226
1247
  * Queries the API for a list of channels based on provided search filters and sort conditions.
1227
1248
  * Also hydrates these channels into the local SDK state memory.
@@ -1263,22 +1284,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1263
1284
  getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1264
1285
  getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1265
1286
  /**
1266
- * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
1267
- * Consumers can customize the `name` field. `members` and `public` fields are constrained.
1287
+ * Creates a quick channel and immediately registers it on the server.
1288
+ * Quick channels are public group channels that anyone can join without an invitation.
1289
+ * The creator is added as the first member automatically.
1268
1290
  *
1269
- * @param name - The custom name for the meeting channel.
1291
+ * @param name - An optional display name for the channel.
1270
1292
  * @returns A promise that resolves to the created `Channel` object.
1271
1293
  */
1272
- createMeetingChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1294
+ createQuickChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1273
1295
  /**
1274
- * Joins a `meeting` channel.
1275
- * It queries/watches the channel to see if caller is already a member.
1276
- * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
1296
+ * Joins a quick channel by its ID.
1297
+ * Automatically checks whether the caller is already a member.
1298
+ * If not, it joins the channel and synchronizes state.
1277
1299
  *
1278
- * @param channelId - The ID of the meeting channel to join.
1300
+ * @param channelId - The ID of the quick channel to join.
1279
1301
  * @returns A promise that resolves to the joined `Channel` object.
1280
1302
  */
1281
- joinMeetingChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1303
+ joinQuickChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1282
1304
  _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
1283
1305
  getUserAgent(): string;
1284
1306
  setUserAgent(userAgent: string): void;
@@ -1676,4 +1698,4 @@ interface SignalMessageResult {
1676
1698
  */
1677
1699
  declare function parseSignalMessage(value: string, myUserId: string): SignalMessageResult | null;
1678
1700
 
1679
- export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
1701
+ export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type CreateTopicData, type DefaultGenerics, EVENT_MAP, type EditMessage, type EditTopicData, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
package/dist/index.d.ts CHANGED
@@ -222,6 +222,7 @@ type ChannelResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGener
222
222
  member_capabilities?: string[];
223
223
  is_pinned?: boolean;
224
224
  topics_enabled?: boolean;
225
+ parent_cid?: string;
225
226
  is_closed_topic?: boolean;
226
227
  };
227
228
  type QueryChannelsAPIResponse<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
@@ -401,6 +402,7 @@ type Event$1<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> = E
401
402
  message?: MessageResponse<ErmisChatGenerics>;
402
403
  online?: boolean;
403
404
  parent_id?: string;
405
+ parent_cid?: string;
404
406
  reaction?: ReactionResponse<ErmisChatGenerics>;
405
407
  received_at?: string | Date;
406
408
  unread_messages?: number;
@@ -428,6 +430,16 @@ type ChannelFilters = {
428
430
  parent_id?: string;
429
431
  include_parent?: boolean;
430
432
  };
433
+ type CreateTopicData = {
434
+ name: string;
435
+ image?: string;
436
+ [key: string]: any;
437
+ };
438
+ type EditTopicData = {
439
+ name?: string;
440
+ image?: string;
441
+ description?: string;
442
+ };
431
443
  type ChannelSort = {
432
444
  field: string;
433
445
  direction: -1 | 1;
@@ -863,6 +875,8 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
863
875
  }): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
864
876
  pinMessage(messageID: string): Promise<unknown>;
865
877
  unpinMessage(messageID: string): Promise<unknown>;
878
+ pin(): Promise<APIResponse>;
879
+ unpin(): Promise<APIResponse>;
866
880
  editMessage(oldMessageID: string, message: EditMessage): Promise<unknown>;
867
881
  sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse<ErmisChatGenerics>): Promise<SendFileAPIResponse>;
868
882
  /**
@@ -961,7 +975,7 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
961
975
  }[];
962
976
  getCapabilitiesMember(): unknown;
963
977
  create: () => Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
964
- createTopic(data: any): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
978
+ createTopic(data: CreateTopicData): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
965
979
  query(options: ChannelQueryOptions, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
966
980
  createDirectChannel(messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
967
981
  queryMessagesLessThanId(message_id: string, limit?: number): Promise<MessageResponse<ErmisChatGenerics>[]>;
@@ -978,7 +992,7 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
978
992
  disableTopics(): Promise<unknown>;
979
993
  closeTopic(topicCID: string): Promise<unknown>;
980
994
  reopenTopic(topicCID: string): Promise<unknown>;
981
- editTopic(topicCID: string, data: any): Promise<any>;
995
+ editTopic(topicCID: string, data: EditTopicData): Promise<any>;
982
996
  on(eventType: EventTypes, callback: EventHandler<ErmisChatGenerics>): {
983
997
  unsubscribe: () => void;
984
998
  };
@@ -1132,8 +1146,8 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1132
1146
  * @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
1133
1147
  * @returns A promise resolving to the API connection response once authenticated.
1134
1148
  */
1135
- connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1136
- setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1149
+ connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1150
+ setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, external_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
1137
1151
  _setToken: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null) => Promise<void>;
1138
1152
  _setUser(user: UserResponse<ErmisChatGenerics>): void;
1139
1153
  closeConnection: (timeout?: number) => Promise<void>;
@@ -1218,10 +1232,17 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1218
1232
  searchUsers(page: number, page_size: number, name?: string): Promise<UsersResponse>;
1219
1233
  queryContacts(): Promise<ContactResult>;
1220
1234
  _updateProjectID(project_id: string): void;
1221
- uploadFile(file: File): Promise<{
1235
+ /**
1236
+ * Uploads a new avatar image for the current user.
1237
+ * The user's avatar URL is automatically updated in both the client and the local state.
1238
+ *
1239
+ * @param file - The image file to upload.
1240
+ * @returns The response containing the new avatar URL.
1241
+ */
1242
+ uploadAvatar(file: File): Promise<{
1222
1243
  avatar: string;
1223
1244
  }>;
1224
- updateProfile(name: string, about_me: string): Promise<UserResponse<ErmisChatGenerics>>;
1245
+ updateProfile(updates: Partial<UserResponse<ErmisChatGenerics>>): Promise<UserResponse<ErmisChatGenerics>>;
1225
1246
  /**
1226
1247
  * Queries the API for a list of channels based on provided search filters and sort conditions.
1227
1248
  * Also hydrates these channels into the local SDK state memory.
@@ -1263,22 +1284,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1263
1284
  getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1264
1285
  getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1265
1286
  /**
1266
- * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
1267
- * Consumers can customize the `name` field. `members` and `public` fields are constrained.
1287
+ * Creates a quick channel and immediately registers it on the server.
1288
+ * Quick channels are public group channels that anyone can join without an invitation.
1289
+ * The creator is added as the first member automatically.
1268
1290
  *
1269
- * @param name - The custom name for the meeting channel.
1291
+ * @param name - An optional display name for the channel.
1270
1292
  * @returns A promise that resolves to the created `Channel` object.
1271
1293
  */
1272
- createMeetingChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1294
+ createQuickChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1273
1295
  /**
1274
- * Joins a `meeting` channel.
1275
- * It queries/watches the channel to see if caller is already a member.
1276
- * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
1296
+ * Joins a quick channel by its ID.
1297
+ * Automatically checks whether the caller is already a member.
1298
+ * If not, it joins the channel and synchronizes state.
1277
1299
  *
1278
- * @param channelId - The ID of the meeting channel to join.
1300
+ * @param channelId - The ID of the quick channel to join.
1279
1301
  * @returns A promise that resolves to the joined `Channel` object.
1280
1302
  */
1281
- joinMeetingChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1303
+ joinQuickChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1282
1304
  _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
1283
1305
  getUserAgent(): string;
1284
1306
  setUserAgent(userAgent: string): void;
@@ -1676,4 +1698,4 @@ interface SignalMessageResult {
1676
1698
  */
1677
1699
  declare function parseSignalMessage(value: string, myUserId: string): SignalMessageResult | null;
1678
1700
 
1679
- export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
1701
+ export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type CreateTopicData, type DefaultGenerics, EVENT_MAP, type EditMessage, type EditTopicData, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
package/dist/index.mjs CHANGED
@@ -1006,6 +1006,44 @@ var Channel = class {
1006
1006
  this.getClient().baseURL + `/messages/${this.type}/${this.id}/${messageID}/unpin`
1007
1007
  );
1008
1008
  }
1009
+ async pin() {
1010
+ if (this.data) this.data.is_pinned = true;
1011
+ this.getClient().dispatchEvent({
1012
+ type: "channel.pinned",
1013
+ cid: this.cid,
1014
+ channel: this.data
1015
+ });
1016
+ try {
1017
+ return await this.getClient().pinChannel(this.type, this.id);
1018
+ } catch (e) {
1019
+ if (this.data) this.data.is_pinned = false;
1020
+ this.getClient().dispatchEvent({
1021
+ type: "channel.unpinned",
1022
+ cid: this.cid,
1023
+ channel: this.data
1024
+ });
1025
+ throw e;
1026
+ }
1027
+ }
1028
+ async unpin() {
1029
+ if (this.data) this.data.is_pinned = false;
1030
+ this.getClient().dispatchEvent({
1031
+ type: "channel.unpinned",
1032
+ cid: this.cid,
1033
+ channel: this.data
1034
+ });
1035
+ try {
1036
+ return await this.getClient().unpinChannel(this.type, this.id);
1037
+ } catch (e) {
1038
+ if (this.data) this.data.is_pinned = true;
1039
+ this.getClient().dispatchEvent({
1040
+ type: "channel.pinned",
1041
+ cid: this.cid,
1042
+ channel: this.data
1043
+ });
1044
+ throw e;
1045
+ }
1046
+ }
1009
1047
  async editMessage(oldMessageID, message) {
1010
1048
  return await this.getClient().post(this.getClient().baseURL + `/messages/${this.type}/${this.id}/${oldMessageID}`, {
1011
1049
  message
@@ -1911,6 +1949,18 @@ var Channel = class {
1911
1949
  delete channelState.members[event.user.id];
1912
1950
  }
1913
1951
  break;
1952
+ case "channel.topic.enabled":
1953
+ if (channel.data) {
1954
+ channel.data.topics_enabled = true;
1955
+ }
1956
+ channelState.topics = channelState.topics || [];
1957
+ break;
1958
+ case "channel.topic.disabled":
1959
+ if (channel.data) {
1960
+ channel.data.topics_enabled = false;
1961
+ }
1962
+ channelState.topics = [];
1963
+ break;
1914
1964
  case "channel.updated":
1915
1965
  if (event.channel) {
1916
1966
  channel.data = {
@@ -2049,7 +2099,12 @@ var Channel = class {
2049
2099
  const topic = this.getClient().channel(event.channel_type || "", event.channel_id || "");
2050
2100
  topic.data = event.channel;
2051
2101
  topic._initializeState(topicState, "latest");
2052
- channelState.topics?.unshift(topic);
2102
+ if (!channelState.topics) {
2103
+ channelState.topics = [];
2104
+ }
2105
+ if (!channelState.topics.some((t) => t.cid === topic.cid)) {
2106
+ channelState.topics.push(topic);
2107
+ }
2053
2108
  break;
2054
2109
  case "channel.topic.closed":
2055
2110
  if (channel.data) {
@@ -2868,7 +2923,6 @@ var ErmisChat = class _ErmisChat {
2868
2923
  params.avatar = user.avatar;
2869
2924
  }
2870
2925
  const url = this.userBaseURL + "/get_token/external_auth";
2871
- const query = new URLSearchParams(params).toString();
2872
2926
  const headers = {
2873
2927
  "Content-Type": "application/json"
2874
2928
  };
@@ -2876,21 +2930,21 @@ var ErmisChat = class _ErmisChat {
2876
2930
  const tokenStr = typeof token === "string" && token.startsWith("Bearer ") ? token : `Bearer ${token}`;
2877
2931
  headers["Authorization"] = tokenStr;
2878
2932
  }
2879
- const response = await fetch(`${url}?${query}`, {
2880
- method: "GET",
2881
- headers
2882
- });
2883
- if (!response.ok) {
2884
- let errorMsg = "";
2885
- try {
2886
- const errorData = await response.json();
2887
- errorMsg = errorData.message || JSON.stringify(errorData);
2888
- } catch {
2889
- errorMsg = await response.text();
2933
+ try {
2934
+ const response = await this.axiosInstance.get(url, {
2935
+ params,
2936
+ headers
2937
+ });
2938
+ return response.data;
2939
+ } catch (error) {
2940
+ let errorMsg = "Failed to fetch external auth token";
2941
+ if (error.response && error.response.data) {
2942
+ errorMsg = error.response.data.message || JSON.stringify(error.response.data);
2943
+ } else if (error.message) {
2944
+ errorMsg = error.message;
2890
2945
  }
2891
2946
  throw new Error(errorMsg);
2892
2947
  }
2893
- return await response.json();
2894
2948
  }
2895
2949
  /**
2896
2950
  * Connects a user to the Ermis network and establishes the WebSocket connection.
@@ -2901,19 +2955,24 @@ var ErmisChat = class _ErmisChat {
2901
2955
  * @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
2902
2956
  * @returns A promise resolving to the API connection response once authenticated.
2903
2957
  */
2904
- connectUser = async (user, userTokenOrProvider, extenal_auth) => {
2958
+ connectUser = async (user, userTokenOrProvider, external_auth) => {
2905
2959
  this.logger("info", "client:connectUser() - started", {
2906
2960
  tags: ["connection", "client"]
2907
2961
  });
2908
2962
  if (!user.id) {
2909
2963
  throw new Error('The "id" field on the user is missing');
2910
2964
  }
2911
- if (extenal_auth) {
2965
+ let connectionUser = user;
2966
+ let connectionToken = userTokenOrProvider;
2967
+ if (external_auth) {
2912
2968
  const external_auth_token = await this.getExternalAuthToken(user, userTokenOrProvider);
2913
- userTokenOrProvider = external_auth_token.token;
2914
- user.id = external_auth_token.user_id;
2969
+ connectionToken = external_auth_token.token;
2970
+ connectionUser = {
2971
+ ...user,
2972
+ id: external_auth_token.user_id
2973
+ };
2915
2974
  }
2916
- if (this.userID === user.id && this.setUserPromise) {
2975
+ if (this.userID === connectionUser.id && this.setUserPromise) {
2917
2976
  console.warn(
2918
2977
  "Consecutive calls to connectUser is detected, ideally you should only call this function once in your app."
2919
2978
  );
@@ -2929,10 +2988,10 @@ var ErmisChat = class _ErmisChat {
2929
2988
  'Please do not use connectUser server side. connectUser impacts MAU and concurrent connection usage and thus your bill. If you have a valid use-case, add "allowServerSideConnect: true" to the client options to disable this warning.'
2930
2989
  );
2931
2990
  }
2932
- this.userID = user.id;
2933
- const setTokenPromise = this._setToken(user, userTokenOrProvider);
2934
- this._setUser(user);
2935
- this.state.updateUser({ id: user.id, name: user?.name || user.id, avatar: user?.avatar || "" });
2991
+ this.userID = connectionUser.id;
2992
+ const setTokenPromise = this._setToken(connectionUser, connectionToken);
2993
+ this._setUser(connectionUser);
2994
+ this.state.updateUser({ id: connectionUser.id, name: connectionUser?.name || connectionUser.id, avatar: connectionUser?.avatar || "" });
2936
2995
  const wsPromise = this.openConnection();
2937
2996
  this.setUserPromise = Promise.all([setTokenPromise, wsPromise]).then(
2938
2997
  (result) => result[1]
@@ -3158,7 +3217,7 @@ var ErmisChat = class _ErmisChat {
3158
3217
  }
3159
3218
  dispatchEvent = (event) => {
3160
3219
  if (!event.received_at) event.received_at = /* @__PURE__ */ new Date();
3161
- if (event.type === "channel.created") {
3220
+ if (event.type === "channel.created" || event.type === "channel.topic.created") {
3162
3221
  this._handleChannelCreatedEvent(event).then(() => {
3163
3222
  this._afterDispatchEvent(event);
3164
3223
  });
@@ -3292,6 +3351,79 @@ var ErmisChat = class _ErmisChat {
3292
3351
  });
3293
3352
  }
3294
3353
  }
3354
+ if (event.type === "message.new" && event.channel_type === "topic") {
3355
+ postListenerCallbacks.push(() => {
3356
+ const parentCid = event.parent_cid || event.channel?.parent_cid;
3357
+ if (parentCid && this.activeChannels[parentCid]) {
3358
+ const parentChannel = this.activeChannels[parentCid];
3359
+ if (parentChannel.state.topics) {
3360
+ parentChannel.state.topics.sort((a, b) => {
3361
+ const aLatest = a.state?.latestMessages?.[a.state.latestMessages.length - 1]?.created_at;
3362
+ const bLatest = b.state?.latestMessages?.[b.state.latestMessages.length - 1]?.created_at;
3363
+ const aTime = aLatest ? new Date(aLatest).getTime() : 0;
3364
+ const bTime = bLatest ? new Date(bLatest).getTime() : 0;
3365
+ return bTime - aTime;
3366
+ });
3367
+ parentChannel._callChannelListeners({ ...event, type: "channel.updated", channel: parentChannel.data });
3368
+ }
3369
+ }
3370
+ });
3371
+ }
3372
+ if (event.type === "channel.topic.updated") {
3373
+ postListenerCallbacks.push(() => {
3374
+ const parentCid = event.parent_cid || event.channel?.parent_cid;
3375
+ if (parentCid && this.activeChannels[parentCid]) {
3376
+ const parentChannel = this.activeChannels[parentCid];
3377
+ if (parentChannel.state?.topics && event.channel) {
3378
+ const topicIndex = parentChannel.state.topics.findIndex((t) => t.cid === event.cid || t.channel?.cid === event.cid);
3379
+ if (topicIndex !== -1) {
3380
+ const t = parentChannel.state.topics[topicIndex];
3381
+ if (t.data) {
3382
+ t.data = { ...t.data, ...event.channel };
3383
+ } else if (t.channel) {
3384
+ t.channel = { ...t.channel, ...event.channel };
3385
+ } else {
3386
+ Object.assign(t, event.channel);
3387
+ }
3388
+ }
3389
+ parentChannel._callChannelListeners({ ...event, type: "channel.updated", channel: parentChannel.data });
3390
+ }
3391
+ }
3392
+ if (event.cid && this.activeChannels[event.cid]) {
3393
+ const topicChannel = this.activeChannels[event.cid];
3394
+ if (event.channel) {
3395
+ topicChannel.data = { ...topicChannel.data, ...event.channel };
3396
+ topicChannel._callChannelListeners({ ...event, type: "channel.updated", channel: topicChannel.data });
3397
+ }
3398
+ }
3399
+ });
3400
+ }
3401
+ if (event.type === "channel.topic.closed" || event.type === "channel.topic.reopen") {
3402
+ postListenerCallbacks.push(() => {
3403
+ const isClosed = event.type === "channel.topic.closed";
3404
+ const parentCid = event.parent_cid;
3405
+ if (parentCid && this.activeChannels[parentCid]) {
3406
+ const parentChannel = this.activeChannels[parentCid];
3407
+ if (parentChannel.state?.topics) {
3408
+ const topicIndex = parentChannel.state.topics.findIndex((t) => t.cid === event.cid || t.channel?.cid === event.cid);
3409
+ if (topicIndex !== -1) {
3410
+ const t = parentChannel.state.topics[topicIndex];
3411
+ if (t.data) t.data.is_closed_topic = isClosed;
3412
+ else if (t.channel) t.channel.is_closed_topic = isClosed;
3413
+ else t.is_closed_topic = isClosed;
3414
+ }
3415
+ parentChannel._callChannelListeners({ ...event, type: "channel.updated", channel: parentChannel.data });
3416
+ }
3417
+ }
3418
+ if (event.cid && this.activeChannels[event.cid]) {
3419
+ const topicChannel = this.activeChannels[event.cid];
3420
+ if (topicChannel.data) {
3421
+ topicChannel.data.is_closed_topic = isClosed;
3422
+ }
3423
+ topicChannel._callChannelListeners({ ...event, type: "channel.updated", channel: topicChannel.data });
3424
+ }
3425
+ });
3426
+ }
3295
3427
  if (event.type === "connection.recovered") {
3296
3428
  postListenerCallbacks.push(() => {
3297
3429
  Object.values(this.activeChannels).forEach((channel) => {
@@ -3529,7 +3661,14 @@ var ErmisChat = class _ErmisChat {
3529
3661
  _updateProjectID(project_id) {
3530
3662
  this.projectId = project_id;
3531
3663
  }
3532
- async uploadFile(file) {
3664
+ /**
3665
+ * Uploads a new avatar image for the current user.
3666
+ * The user's avatar URL is automatically updated in both the client and the local state.
3667
+ *
3668
+ * @param file - The image file to upload.
3669
+ * @returns The response containing the new avatar URL.
3670
+ */
3671
+ async uploadAvatar(file) {
3533
3672
  const formData = new FormData();
3534
3673
  formData.append("avatar", file);
3535
3674
  let response = await this.post(this.userBaseURL + "/users/upload", formData, {
@@ -3544,12 +3683,8 @@ var ErmisChat = class _ErmisChat {
3544
3683
  }
3545
3684
  return response;
3546
3685
  }
3547
- async updateProfile(name, about_me) {
3548
- let body = {
3549
- name,
3550
- about_me
3551
- };
3552
- let response = await this.patch(this.userBaseURL + "/users/update", body);
3686
+ async updateProfile(updates) {
3687
+ let response = await this.patch(this.userBaseURL + "/users/update", updates);
3553
3688
  this.user = response;
3554
3689
  this.state.updateUser(response);
3555
3690
  return response;
@@ -3702,45 +3837,55 @@ var ErmisChat = class _ErmisChat {
3702
3837
  return channel;
3703
3838
  };
3704
3839
  /**
3705
- * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
3706
- * Consumers can customize the `name` field. `members` and `public` fields are constrained.
3840
+ * Creates a quick channel and immediately registers it on the server.
3841
+ * Quick channels are public group channels that anyone can join without an invitation.
3842
+ * The creator is added as the first member automatically.
3707
3843
  *
3708
- * @param name - The custom name for the meeting channel.
3844
+ * @param name - An optional display name for the channel.
3709
3845
  * @returns A promise that resolves to the created `Channel` object.
3710
3846
  */
3711
- async createMeetingChannel(name) {
3847
+ async createQuickChannel(name) {
3712
3848
  if (!this.userID) {
3713
3849
  throw Error("Call connectUser before creating a channel");
3714
3850
  }
3851
+ const now = /* @__PURE__ */ new Date();
3852
+ const formattedDate = new Intl.DateTimeFormat("en-US", {
3853
+ month: "short",
3854
+ day: "2-digit",
3855
+ year: "numeric",
3856
+ hour: "2-digit",
3857
+ minute: "2-digit",
3858
+ hour12: false
3859
+ }).format(now);
3715
3860
  const payload = {
3716
- name: name || `Meeting Public - ${(/* @__PURE__ */ new Date()).toISOString()}`,
3861
+ name: name || `Quick Channel - ${formattedDate}`,
3717
3862
  members: [this.userID],
3718
3863
  public: true
3719
3864
  };
3720
- const meetingChannel = this.channel("meeting", payload);
3721
- await meetingChannel.create();
3722
- return meetingChannel;
3865
+ const quickChannel = this.channel("meeting", payload);
3866
+ await quickChannel.create();
3867
+ return quickChannel;
3723
3868
  }
3724
3869
  /**
3725
- * Joins a `meeting` channel.
3726
- * It queries/watches the channel to see if caller is already a member.
3727
- * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
3870
+ * Joins a quick channel by its ID.
3871
+ * Automatically checks whether the caller is already a member.
3872
+ * If not, it joins the channel and synchronizes state.
3728
3873
  *
3729
- * @param channelId - The ID of the meeting channel to join.
3874
+ * @param channelId - The ID of the quick channel to join.
3730
3875
  * @returns A promise that resolves to the joined `Channel` object.
3731
3876
  */
3732
- async joinMeetingChannel(channelId) {
3877
+ async joinQuickChannel(channelId) {
3733
3878
  if (!this.userID) {
3734
3879
  throw Error("Call connectUser before joining a channel");
3735
3880
  }
3736
- const meetingChannel = this.channel("meeting", channelId);
3737
- await meetingChannel.watch();
3738
- const isMember = meetingChannel.state.members && meetingChannel.state.members[this.userID];
3881
+ const quickChannel = this.channel("meeting", channelId);
3882
+ await quickChannel.watch();
3883
+ const isMember = quickChannel.state.members && quickChannel.state.members[this.userID];
3739
3884
  if (!isMember) {
3740
- await meetingChannel.acceptInvite("join");
3741
- await meetingChannel.watch();
3885
+ await quickChannel.acceptInvite("join");
3886
+ await quickChannel.watch();
3742
3887
  }
3743
- return meetingChannel;
3888
+ return quickChannel;
3744
3889
  }
3745
3890
  _normalizeExpiration(timeoutOrExpirationDate) {
3746
3891
  let pinExpires = null;
@@ -3756,7 +3901,7 @@ var ErmisChat = class _ErmisChat {
3756
3901
  return pinExpires;
3757
3902
  }
3758
3903
  getUserAgent() {
3759
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
3904
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.7"}`;
3760
3905
  }
3761
3906
  setUserAgent(userAgent) {
3762
3907
  this.userAgent = userAgent;
@@ -7115,7 +7260,7 @@ var ErmisAuthProvider = class {
7115
7260
  return data;
7116
7261
  }
7117
7262
  getUserAgent() {
7118
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
7263
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.7"}`;
7119
7264
  }
7120
7265
  setUserAgent(userAgent) {
7121
7266
  this.userAgent = userAgent;