@ermis-network/ermis-chat-sdk 1.0.3 → 1.0.4
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.browser.cjs +122 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.full-bundle.min.js +2 -2
- package/dist/index.browser.full-bundle.min.js.map +1 -1
- package/dist/index.browser.mjs +122 -2
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +122 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +173 -0
- package/dist/index.d.ts +173 -0
- package/dist/index.mjs +122 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +42 -0
- package/src/channel_state.ts +27 -0
- package/src/client.ts +104 -0
package/dist/index.d.mts
CHANGED
|
@@ -664,18 +664,30 @@ type ChannelReadStatus<ErmisChatGenerics extends ExtendableGenerics = DefaultGen
|
|
|
664
664
|
}>;
|
|
665
665
|
/**
|
|
666
666
|
* ChannelState - A container class for the channel state.
|
|
667
|
+
* This class synchronously binds to a `Channel` and holds the single source of truth for
|
|
668
|
+
* messages, read status, watchers, and typing indicators locally on the client.
|
|
667
669
|
*/
|
|
668
670
|
declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
669
671
|
_channel: Channel<ErmisChatGenerics>;
|
|
672
|
+
/** The current count of users actively watching (having an open WebSocket) this channel. */
|
|
670
673
|
watcher_count: number;
|
|
674
|
+
/** A dictionary of active typing events gracefully keyed by the user's ID. */
|
|
671
675
|
typing: Record<string, Event$1<ErmisChatGenerics>>;
|
|
676
|
+
/** A dictionary of read states mapped per user's ID detailing the last viewed message. */
|
|
672
677
|
read: ChannelReadStatus<ErmisChatGenerics>;
|
|
678
|
+
/** The locally cached array of pinned messages across the channel. */
|
|
673
679
|
pinnedMessages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>;
|
|
680
|
+
/** A directory of users actively watching the channel, keyed by User ID. */
|
|
674
681
|
watchers: Record<string, UserResponse<ErmisChatGenerics>>;
|
|
682
|
+
/** A comprehensive directory mapping user IDs to their member status in the channel. */
|
|
675
683
|
members: Record<string, ChannelMemberResponse<ErmisChatGenerics>>;
|
|
684
|
+
/** The count of messages not yet read by the currently authenticated user. */
|
|
676
685
|
unreadCount: number;
|
|
686
|
+
/** Information detailing the authenticated user's own membership relation to this channel. */
|
|
677
687
|
membership: ChannelMembership<ErmisChatGenerics>;
|
|
688
|
+
/** Timestamp indicating when the very last message was created in this chat. */
|
|
678
689
|
last_message_at: Date | null;
|
|
690
|
+
/** Designates if the local channel state is entirely synchronized with the backend history. */
|
|
679
691
|
isUpToDate: boolean;
|
|
680
692
|
messageSets: {
|
|
681
693
|
isCurrent: boolean;
|
|
@@ -688,6 +700,15 @@ declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
688
700
|
set messages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
|
|
689
701
|
get latestMessages(): Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
|
|
690
702
|
set latestMessages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
|
|
703
|
+
/**
|
|
704
|
+
* Pushes a new message directly into the sorted array of the local tracking state.
|
|
705
|
+
* Useful to achieve optimistic UI updates locally.
|
|
706
|
+
*
|
|
707
|
+
* @param newMessage - The message context payload to insert.
|
|
708
|
+
* @param timestampChanged - Specifies if the underlying `created_at` timestamp mutated.
|
|
709
|
+
* @param addIfDoesNotExist - Append it strictly if its ID doesn't already exist.
|
|
710
|
+
* @param messageSetToAddToIfDoesNotExist - Specifies which message set scope to manipulate.
|
|
711
|
+
*/
|
|
691
712
|
addMessageSorted(newMessage: MessageResponse<ErmisChatGenerics>, timestampChanged?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
|
|
692
713
|
messageSet: {
|
|
693
714
|
isCurrent: boolean;
|
|
@@ -734,6 +755,12 @@ declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
734
755
|
removed: boolean;
|
|
735
756
|
result: FormatMessageResponse<ErmisChatGenerics>[];
|
|
736
757
|
};
|
|
758
|
+
/**
|
|
759
|
+
* Refreshes internal user references cascading across all presently active messages.
|
|
760
|
+
* Invoked instantly whenever an underlying user's profile metadata updates (e.g. name or avatar changes).
|
|
761
|
+
*
|
|
762
|
+
* @param user - The newly formatted and populated User details object.
|
|
763
|
+
*/
|
|
737
764
|
updateUserMessages: (user: UserResponse<ErmisChatGenerics>) => void;
|
|
738
765
|
deleteUserMessages: (user: UserResponse<ErmisChatGenerics>, hardDelete?: boolean) => void;
|
|
739
766
|
filterErrorMessages(): void;
|
|
@@ -786,6 +813,11 @@ type VoiceRecordingMeta = {
|
|
|
786
813
|
*/
|
|
787
814
|
declare function buildAttachmentPayload(file: File, uploadedUrl: string, thumbUrl?: string, voiceMeta?: VoiceRecordingMeta): Attachment;
|
|
788
815
|
|
|
816
|
+
/**
|
|
817
|
+
* Represents a Channel in the Ermis Network.
|
|
818
|
+
* Channels handle chat sessions, livestream messages, teams, or video calls.
|
|
819
|
+
* This class abstracts and exposes all API operations you can perform on a specific channel instance.
|
|
820
|
+
*/
|
|
789
821
|
declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
790
822
|
_client: ErmisChat<ErmisChatGenerics>;
|
|
791
823
|
type: string;
|
|
@@ -803,8 +835,24 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
803
835
|
lastTypingEvent: Date | null;
|
|
804
836
|
isTyping: boolean;
|
|
805
837
|
disconnected: boolean;
|
|
838
|
+
/**
|
|
839
|
+
* Initializes a new Channel class instance.
|
|
840
|
+
* Normally you should not call this directly; use `client.channel(type, id)` instead.
|
|
841
|
+
*
|
|
842
|
+
* @param client - The shared ErmisChat client instance initializing this channel.
|
|
843
|
+
* @param type - The type of channel (`messaging`, `team`, `livestream`, etc.).
|
|
844
|
+
* @param id - The unique ID of the channel.
|
|
845
|
+
* @param data - Initial arbitrary metadata stored within this channel.
|
|
846
|
+
*/
|
|
806
847
|
constructor(client: ErmisChat<ErmisChatGenerics>, type: string, id: string | undefined, data: ChannelData<ErmisChatGenerics>);
|
|
807
848
|
getClient(): ErmisChat<ErmisChatGenerics>;
|
|
849
|
+
/**
|
|
850
|
+
* Sends a message to this channel.
|
|
851
|
+
* By default, it pushes the message eagerly (optimistically) to the local UI state before the server replies.
|
|
852
|
+
*
|
|
853
|
+
* @param message - The constructed text/attachment object payload representing the message.
|
|
854
|
+
* @returns A Promise resolving to the exact API response encompassing message details.
|
|
855
|
+
*/
|
|
808
856
|
sendMessage(message: Message<ErmisChatGenerics>): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
809
857
|
retryMessage(messageId: string): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
810
858
|
createPoll(pollMessage: PollMessage): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
@@ -846,6 +894,11 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
846
894
|
acceptInvite(action: string): Promise<APIResponse>;
|
|
847
895
|
rejectInvite(): Promise<APIResponse>;
|
|
848
896
|
skipInvite(): Promise<APIResponse>;
|
|
897
|
+
/**
|
|
898
|
+
* Directly invites or adds registered users into this channel.
|
|
899
|
+
*
|
|
900
|
+
* @param members - Array of user IDs explicitly selected to be added.
|
|
901
|
+
*/
|
|
849
902
|
addMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
850
903
|
addModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
851
904
|
banMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
@@ -863,6 +916,11 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
863
916
|
setSlowMode(cooldown: 0 | 10000 | 30000 | 60000 | 300000 | 900000 | 3600000): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
864
917
|
queryAttachmentMessages(): Promise<AttachmentResponse<ErmisChatGenerics>>;
|
|
865
918
|
searchMessage(search_term: string, offset: number): Promise<any>;
|
|
919
|
+
/**
|
|
920
|
+
* Expels specified currently participating users out of the channel.
|
|
921
|
+
*
|
|
922
|
+
* @param members - Array of user IDs to strictly remove from this chat.
|
|
923
|
+
*/
|
|
866
924
|
removeMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
867
925
|
demoteModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
868
926
|
_update(payload: Object): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
@@ -877,8 +935,19 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
877
935
|
}): Promise<void>;
|
|
878
936
|
_isTypingIndicatorsEnabled(): boolean;
|
|
879
937
|
lastMessage(): FormatMessageResponse<ErmisChatGenerics>;
|
|
938
|
+
/**
|
|
939
|
+
* Emits a mark-read event, updating the backend that the authenticated user has viewed up to the latest known message.
|
|
940
|
+
* @returns Successful acknowledgement from the server.
|
|
941
|
+
*/
|
|
880
942
|
markRead(): Promise<unknown>;
|
|
881
943
|
clean(): void;
|
|
944
|
+
/**
|
|
945
|
+
* Subscribes to realtime events (WebSocket) for this channel, grabs the latest available metadata,
|
|
946
|
+
* loads the most recent messages, and initializes the local state.
|
|
947
|
+
*
|
|
948
|
+
* @param options - Pagination limits like `{ watch: true, presence: true, state: true }`.
|
|
949
|
+
* @returns The synchronized comprehensive channel state.
|
|
950
|
+
*/
|
|
882
951
|
watch(options?: ChannelQueryOptions): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
|
|
883
952
|
lastRead(): Date | null | undefined;
|
|
884
953
|
_countMessageAsUnread(message: FormatMessageResponse<ErmisChatGenerics> | MessageResponse<ErmisChatGenerics>): boolean;
|
|
@@ -978,42 +1047,91 @@ declare class TokenManager<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
978
1047
|
getToken: () => string | undefined;
|
|
979
1048
|
}
|
|
980
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* The ErmisChat Client represents the connection securely established between your application
|
|
1052
|
+
* and the Ermis core servers. It acts as the primary access point for real-time messaging,
|
|
1053
|
+
* presence updates, call management, and channel querying.
|
|
1054
|
+
*
|
|
1055
|
+
* It is highly recommended to instantiate this class as a Singleton via `ErmisChat.getInstance()`.
|
|
1056
|
+
*/
|
|
981
1057
|
declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
982
1058
|
private static _instance?;
|
|
1059
|
+
/** A map of active channels currently tracked by the client, keyed by Channel ID. */
|
|
983
1060
|
activeChannels: {
|
|
984
1061
|
[key: string]: Channel<ErmisChatGenerics>;
|
|
985
1062
|
};
|
|
1063
|
+
/** The internal configured Axios instance used for REST API requests. */
|
|
986
1064
|
axiosInstance: AxiosInstance;
|
|
1065
|
+
/** The primary base URL for REST API communication. */
|
|
987
1066
|
baseURL?: string;
|
|
1067
|
+
/** The specific base URL for standard user-focused REST calls. */
|
|
988
1068
|
userBaseURL?: string;
|
|
1069
|
+
/** True when the SDK is executed inside a browser environment. */
|
|
989
1070
|
browser: boolean;
|
|
990
1071
|
cleaningIntervalRef?: NodeJS.Timeout;
|
|
991
1072
|
clientID?: string;
|
|
992
1073
|
apiKey: string;
|
|
993
1074
|
projectId: string;
|
|
1075
|
+
/** Internal mapped registry of event listeners. */
|
|
994
1076
|
listeners: Record<string, Array<(event: Event$1<ErmisChatGenerics>) => void>>;
|
|
995
1077
|
logger: Logger;
|
|
1078
|
+
/** Whether the client should automatically fetch missing messages upon unexpected disconnects. */
|
|
996
1079
|
recoverStateOnReconnect?: boolean;
|
|
1080
|
+
/** True when the SDK is executed in a NodeJS environment constraint. */
|
|
997
1081
|
node: boolean;
|
|
1082
|
+
/** Custom options passed during client initialization. */
|
|
998
1083
|
options: ErmisChatOptions;
|
|
999
1084
|
setUserPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
|
|
1085
|
+
/** Centralized global state orchestrating user and client metadata. */
|
|
1000
1086
|
state: ClientState<ErmisChatGenerics>;
|
|
1001
1087
|
tokenManager: TokenManager<ErmisChatGenerics>;
|
|
1088
|
+
/** The globally authenticated current user object. */
|
|
1002
1089
|
user?: UserResponse<ErmisChatGenerics>;
|
|
1003
1090
|
userAgent?: string;
|
|
1091
|
+
/** The unique ID of the current authenticated user. */
|
|
1004
1092
|
userID?: string;
|
|
1093
|
+
/** The configured WebSocket endpoint base URL for realtime subscriptions. */
|
|
1005
1094
|
wsBaseURL?: string;
|
|
1095
|
+
/** The active WebSocket connection controller. */
|
|
1006
1096
|
wsConnection: StableWSConnection<ErmisChatGenerics> | null;
|
|
1007
1097
|
wsPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
|
|
1098
|
+
/** Tracks consecutive REST API failures for exponential backoff purposes. */
|
|
1008
1099
|
consecutiveFailures: number;
|
|
1009
1100
|
defaultWSTimeout: number;
|
|
1010
1101
|
private eventSource;
|
|
1102
|
+
/**
|
|
1103
|
+
* Initializes a new Ermis Chat Client instance.
|
|
1104
|
+
*
|
|
1105
|
+
* @param apiKey - Your public Ermis Network API Key.
|
|
1106
|
+
* @param projectId - Your specific Project UUID pointing to the app config.
|
|
1107
|
+
* @param baseURL - The API base endpoint assigned to your project.
|
|
1108
|
+
* @param options - Additional connection rules and configuration options.
|
|
1109
|
+
*/
|
|
1011
1110
|
constructor(apiKey: string, projectId: string, baseURL: string, options?: ErmisChatOptions);
|
|
1111
|
+
/**
|
|
1112
|
+
* Retrieves the globally registered Singleton instance of the ErmisChat client.
|
|
1113
|
+
* If the instance lacks existence, it initializes a new one.
|
|
1114
|
+
*
|
|
1115
|
+
* @param key - Your public Ermis Network API Key.
|
|
1116
|
+
* @param projectId - Your specific Project UUID.
|
|
1117
|
+
* @param baseURL - The API base endpoint.
|
|
1118
|
+
* @param options - Connection options.
|
|
1119
|
+
* @returns The shared ErmisChat client instance.
|
|
1120
|
+
*/
|
|
1012
1121
|
static getInstance<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics>(key: string, projectId: string, baseURL: string, options?: ErmisChatOptions): ErmisChat<ErmisChatGenerics>;
|
|
1013
1122
|
refreshNewToken(refresh_token: string): Promise<APIResponse>;
|
|
1014
1123
|
getAuthType(): string;
|
|
1015
1124
|
setBaseURL(baseURL: string): void;
|
|
1016
1125
|
getExternalAuthToken(user: UserResponse<ErmisChatGenerics>, token: string | null): Promise<any>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Connects a user to the Ermis network and establishes the WebSocket connection.
|
|
1128
|
+
* This is the primary method to authenticate your client application.
|
|
1129
|
+
*
|
|
1130
|
+
* @param user - The User object containing `id`, `name`, and optional `avatar`.
|
|
1131
|
+
* @param userTokenOrProvider - The JWT token or an async token provider function.
|
|
1132
|
+
* @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
|
|
1133
|
+
* @returns A promise resolving to the API connection response once authenticated.
|
|
1134
|
+
*/
|
|
1017
1135
|
connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1018
1136
|
setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1019
1137
|
_setToken: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null) => Promise<void>;
|
|
@@ -1021,15 +1139,44 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1021
1139
|
closeConnection: (timeout?: number) => Promise<void>;
|
|
1022
1140
|
openConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1023
1141
|
_setupConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Gracefully disconnects the current user, terminates the WebSocket connection,
|
|
1144
|
+
* cleans up listeners, and resets the client's internal references.
|
|
1145
|
+
*
|
|
1146
|
+
* @param timeout - Optional timeout in milliseconds before forcing the disconnect.
|
|
1147
|
+
*/
|
|
1024
1148
|
disconnectUser: (timeout?: number) => Promise<void>;
|
|
1025
1149
|
disconnect: (timeout?: number) => Promise<void>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Attaches an event listener to the client connection.
|
|
1152
|
+
* Listeners can be scoped to specific event types (e.g. `message.new`) or listen to `all` events.
|
|
1153
|
+
*
|
|
1154
|
+
* @param callback - The handler invoked when the event is emitted.
|
|
1155
|
+
* @returns An object containing an `unsubscribe` method to detach the listener.
|
|
1156
|
+
*/
|
|
1026
1157
|
on(callback: EventHandler<ErmisChatGenerics>): {
|
|
1027
1158
|
unsubscribe: () => void;
|
|
1028
1159
|
};
|
|
1160
|
+
/**
|
|
1161
|
+
* Attaches an event listener filtered by a specific event type.
|
|
1162
|
+
*
|
|
1163
|
+
* @param eventType - The specific event name to listen for (e.g., `'notification.message_new'`).
|
|
1164
|
+
* @param callback - The handler invoked when the event is emitted.
|
|
1165
|
+
* @returns An object containing an `unsubscribe` method to detach the listener.
|
|
1166
|
+
*/
|
|
1029
1167
|
on(eventType: string, callback: EventHandler<ErmisChatGenerics>): {
|
|
1030
1168
|
unsubscribe: () => void;
|
|
1031
1169
|
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Detaches a previously registered general event listener.
|
|
1172
|
+
* @param callback - The original handler reference to remove.
|
|
1173
|
+
*/
|
|
1032
1174
|
off(callback: EventHandler<ErmisChatGenerics>): void;
|
|
1175
|
+
/**
|
|
1176
|
+
* Detaches a previously registered event listener scoped to a specific event type.
|
|
1177
|
+
* @param eventType - The specific event name.
|
|
1178
|
+
* @param callback - The original handler reference to remove.
|
|
1179
|
+
*/
|
|
1033
1180
|
off(eventType: string, callback: EventHandler<ErmisChatGenerics>): void;
|
|
1034
1181
|
_logApiRequest(type: string, url: string, data: unknown, config: AxiosRequestConfig & {
|
|
1035
1182
|
config?: AxiosRequestConfig & {
|
|
@@ -1075,6 +1222,16 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1075
1222
|
avatar: string;
|
|
1076
1223
|
}>;
|
|
1077
1224
|
updateProfile(name: string, about_me: string): Promise<UserResponse<ErmisChatGenerics>>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Queries the API for a list of channels based on provided search filters and sort conditions.
|
|
1227
|
+
* Also hydrates these channels into the local SDK state memory.
|
|
1228
|
+
*
|
|
1229
|
+
* @param filterConditions - Specific criteria to filter channels (e.g. `{ type: 'messaging', members: { $in: ['user1'] } }`).
|
|
1230
|
+
* @param sort - The sorting hierarchy applied to the channel results.
|
|
1231
|
+
* @param options - Pagination and message limit parameters.
|
|
1232
|
+
* @param stateOptions - Defines whether to skip state initialization or offline usage.
|
|
1233
|
+
* @returns An array of hydrated and locally manageable `Channel` objects.
|
|
1234
|
+
*/
|
|
1078
1235
|
queryChannels(filterConditions: ChannelFilters, sort?: ChannelSort, options?: {
|
|
1079
1236
|
message_limit?: number;
|
|
1080
1237
|
}, stateOptions?: ChannelStateOptions): Promise<Channel<ErmisChatGenerics>[]>;
|
|
@@ -1085,7 +1242,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1085
1242
|
searchPublicChannel(search_term: string, offset?: number, limit?: number): Promise<APIResponse>;
|
|
1086
1243
|
pinChannel(channelType: string, channelId: string): Promise<APIResponse>;
|
|
1087
1244
|
unpinChannel(channelType: string, channelId: string): Promise<APIResponse>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Creates or instantiates an interactive `Channel` object locally based on type and custom data.
|
|
1247
|
+
* This does NOT immediately ping the API unless `channel.watch()` or `channel.create()` is subsequently called.
|
|
1248
|
+
*
|
|
1249
|
+
* @param type - The strict channel type descriptor (e.g., `'messaging'`, `'team'`, `'livestream'`).
|
|
1250
|
+
* @param custom - Initial metadata or specific members to include in the channel.
|
|
1251
|
+
* @returns A newly instantiated `Channel` object.
|
|
1252
|
+
*/
|
|
1088
1253
|
channel(type: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Creates or instantiates an interactive `Channel` object locally using a specific ID.
|
|
1256
|
+
*
|
|
1257
|
+
* @param type - The strict channel type descriptor.
|
|
1258
|
+
* @param id - The unique identifer (UUID / slug) for the channel.
|
|
1259
|
+
* @param custom - Initial metadata or specific members to include in the channel.
|
|
1260
|
+
* @returns A newly instantiated `Channel` object.
|
|
1261
|
+
*/
|
|
1089
1262
|
channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1090
1263
|
getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
|
|
1091
1264
|
getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
|
package/dist/index.d.ts
CHANGED
|
@@ -664,18 +664,30 @@ type ChannelReadStatus<ErmisChatGenerics extends ExtendableGenerics = DefaultGen
|
|
|
664
664
|
}>;
|
|
665
665
|
/**
|
|
666
666
|
* ChannelState - A container class for the channel state.
|
|
667
|
+
* This class synchronously binds to a `Channel` and holds the single source of truth for
|
|
668
|
+
* messages, read status, watchers, and typing indicators locally on the client.
|
|
667
669
|
*/
|
|
668
670
|
declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
669
671
|
_channel: Channel<ErmisChatGenerics>;
|
|
672
|
+
/** The current count of users actively watching (having an open WebSocket) this channel. */
|
|
670
673
|
watcher_count: number;
|
|
674
|
+
/** A dictionary of active typing events gracefully keyed by the user's ID. */
|
|
671
675
|
typing: Record<string, Event$1<ErmisChatGenerics>>;
|
|
676
|
+
/** A dictionary of read states mapped per user's ID detailing the last viewed message. */
|
|
672
677
|
read: ChannelReadStatus<ErmisChatGenerics>;
|
|
678
|
+
/** The locally cached array of pinned messages across the channel. */
|
|
673
679
|
pinnedMessages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>;
|
|
680
|
+
/** A directory of users actively watching the channel, keyed by User ID. */
|
|
674
681
|
watchers: Record<string, UserResponse<ErmisChatGenerics>>;
|
|
682
|
+
/** A comprehensive directory mapping user IDs to their member status in the channel. */
|
|
675
683
|
members: Record<string, ChannelMemberResponse<ErmisChatGenerics>>;
|
|
684
|
+
/** The count of messages not yet read by the currently authenticated user. */
|
|
676
685
|
unreadCount: number;
|
|
686
|
+
/** Information detailing the authenticated user's own membership relation to this channel. */
|
|
677
687
|
membership: ChannelMembership<ErmisChatGenerics>;
|
|
688
|
+
/** Timestamp indicating when the very last message was created in this chat. */
|
|
678
689
|
last_message_at: Date | null;
|
|
690
|
+
/** Designates if the local channel state is entirely synchronized with the backend history. */
|
|
679
691
|
isUpToDate: boolean;
|
|
680
692
|
messageSets: {
|
|
681
693
|
isCurrent: boolean;
|
|
@@ -688,6 +700,15 @@ declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
688
700
|
set messages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
|
|
689
701
|
get latestMessages(): Array<ReturnType<ChannelState<ErmisChatGenerics>["formatMessage"]>>;
|
|
690
702
|
set latestMessages(messages: Array<ReturnType<ChannelState<ErmisChatGenerics>['formatMessage']>>);
|
|
703
|
+
/**
|
|
704
|
+
* Pushes a new message directly into the sorted array of the local tracking state.
|
|
705
|
+
* Useful to achieve optimistic UI updates locally.
|
|
706
|
+
*
|
|
707
|
+
* @param newMessage - The message context payload to insert.
|
|
708
|
+
* @param timestampChanged - Specifies if the underlying `created_at` timestamp mutated.
|
|
709
|
+
* @param addIfDoesNotExist - Append it strictly if its ID doesn't already exist.
|
|
710
|
+
* @param messageSetToAddToIfDoesNotExist - Specifies which message set scope to manipulate.
|
|
711
|
+
*/
|
|
691
712
|
addMessageSorted(newMessage: MessageResponse<ErmisChatGenerics>, timestampChanged?: boolean, addIfDoesNotExist?: boolean, messageSetToAddToIfDoesNotExist?: MessageSetType): {
|
|
692
713
|
messageSet: {
|
|
693
714
|
isCurrent: boolean;
|
|
@@ -734,6 +755,12 @@ declare class ChannelState<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
734
755
|
removed: boolean;
|
|
735
756
|
result: FormatMessageResponse<ErmisChatGenerics>[];
|
|
736
757
|
};
|
|
758
|
+
/**
|
|
759
|
+
* Refreshes internal user references cascading across all presently active messages.
|
|
760
|
+
* Invoked instantly whenever an underlying user's profile metadata updates (e.g. name or avatar changes).
|
|
761
|
+
*
|
|
762
|
+
* @param user - The newly formatted and populated User details object.
|
|
763
|
+
*/
|
|
737
764
|
updateUserMessages: (user: UserResponse<ErmisChatGenerics>) => void;
|
|
738
765
|
deleteUserMessages: (user: UserResponse<ErmisChatGenerics>, hardDelete?: boolean) => void;
|
|
739
766
|
filterErrorMessages(): void;
|
|
@@ -786,6 +813,11 @@ type VoiceRecordingMeta = {
|
|
|
786
813
|
*/
|
|
787
814
|
declare function buildAttachmentPayload(file: File, uploadedUrl: string, thumbUrl?: string, voiceMeta?: VoiceRecordingMeta): Attachment;
|
|
788
815
|
|
|
816
|
+
/**
|
|
817
|
+
* Represents a Channel in the Ermis Network.
|
|
818
|
+
* Channels handle chat sessions, livestream messages, teams, or video calls.
|
|
819
|
+
* This class abstracts and exposes all API operations you can perform on a specific channel instance.
|
|
820
|
+
*/
|
|
789
821
|
declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
790
822
|
_client: ErmisChat<ErmisChatGenerics>;
|
|
791
823
|
type: string;
|
|
@@ -803,8 +835,24 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
803
835
|
lastTypingEvent: Date | null;
|
|
804
836
|
isTyping: boolean;
|
|
805
837
|
disconnected: boolean;
|
|
838
|
+
/**
|
|
839
|
+
* Initializes a new Channel class instance.
|
|
840
|
+
* Normally you should not call this directly; use `client.channel(type, id)` instead.
|
|
841
|
+
*
|
|
842
|
+
* @param client - The shared ErmisChat client instance initializing this channel.
|
|
843
|
+
* @param type - The type of channel (`messaging`, `team`, `livestream`, etc.).
|
|
844
|
+
* @param id - The unique ID of the channel.
|
|
845
|
+
* @param data - Initial arbitrary metadata stored within this channel.
|
|
846
|
+
*/
|
|
806
847
|
constructor(client: ErmisChat<ErmisChatGenerics>, type: string, id: string | undefined, data: ChannelData<ErmisChatGenerics>);
|
|
807
848
|
getClient(): ErmisChat<ErmisChatGenerics>;
|
|
849
|
+
/**
|
|
850
|
+
* Sends a message to this channel.
|
|
851
|
+
* By default, it pushes the message eagerly (optimistically) to the local UI state before the server replies.
|
|
852
|
+
*
|
|
853
|
+
* @param message - The constructed text/attachment object payload representing the message.
|
|
854
|
+
* @returns A Promise resolving to the exact API response encompassing message details.
|
|
855
|
+
*/
|
|
808
856
|
sendMessage(message: Message<ErmisChatGenerics>): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
809
857
|
retryMessage(messageId: string): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
810
858
|
createPoll(pollMessage: PollMessage): Promise<SendMessageAPIResponse<ErmisChatGenerics>>;
|
|
@@ -846,6 +894,11 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
846
894
|
acceptInvite(action: string): Promise<APIResponse>;
|
|
847
895
|
rejectInvite(): Promise<APIResponse>;
|
|
848
896
|
skipInvite(): Promise<APIResponse>;
|
|
897
|
+
/**
|
|
898
|
+
* Directly invites or adds registered users into this channel.
|
|
899
|
+
*
|
|
900
|
+
* @param members - Array of user IDs explicitly selected to be added.
|
|
901
|
+
*/
|
|
849
902
|
addMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
850
903
|
addModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
851
904
|
banMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
@@ -863,6 +916,11 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
863
916
|
setSlowMode(cooldown: 0 | 10000 | 30000 | 60000 | 300000 | 900000 | 3600000): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
864
917
|
queryAttachmentMessages(): Promise<AttachmentResponse<ErmisChatGenerics>>;
|
|
865
918
|
searchMessage(search_term: string, offset: number): Promise<any>;
|
|
919
|
+
/**
|
|
920
|
+
* Expels specified currently participating users out of the channel.
|
|
921
|
+
*
|
|
922
|
+
* @param members - Array of user IDs to strictly remove from this chat.
|
|
923
|
+
*/
|
|
866
924
|
removeMembers(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
867
925
|
demoteModerators(members: string[]): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
868
926
|
_update(payload: Object): Promise<UpdateChannelAPIResponse<ErmisChatGenerics>>;
|
|
@@ -877,8 +935,19 @@ declare class Channel<ErmisChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
877
935
|
}): Promise<void>;
|
|
878
936
|
_isTypingIndicatorsEnabled(): boolean;
|
|
879
937
|
lastMessage(): FormatMessageResponse<ErmisChatGenerics>;
|
|
938
|
+
/**
|
|
939
|
+
* Emits a mark-read event, updating the backend that the authenticated user has viewed up to the latest known message.
|
|
940
|
+
* @returns Successful acknowledgement from the server.
|
|
941
|
+
*/
|
|
880
942
|
markRead(): Promise<unknown>;
|
|
881
943
|
clean(): void;
|
|
944
|
+
/**
|
|
945
|
+
* Subscribes to realtime events (WebSocket) for this channel, grabs the latest available metadata,
|
|
946
|
+
* loads the most recent messages, and initializes the local state.
|
|
947
|
+
*
|
|
948
|
+
* @param options - Pagination limits like `{ watch: true, presence: true, state: true }`.
|
|
949
|
+
* @returns The synchronized comprehensive channel state.
|
|
950
|
+
*/
|
|
882
951
|
watch(options?: ChannelQueryOptions): Promise<QueryChannelAPIResponse<ErmisChatGenerics>>;
|
|
883
952
|
lastRead(): Date | null | undefined;
|
|
884
953
|
_countMessageAsUnread(message: FormatMessageResponse<ErmisChatGenerics> | MessageResponse<ErmisChatGenerics>): boolean;
|
|
@@ -978,42 +1047,91 @@ declare class TokenManager<ErmisChatGenerics extends ExtendableGenerics = Defaul
|
|
|
978
1047
|
getToken: () => string | undefined;
|
|
979
1048
|
}
|
|
980
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* The ErmisChat Client represents the connection securely established between your application
|
|
1052
|
+
* and the Ermis core servers. It acts as the primary access point for real-time messaging,
|
|
1053
|
+
* presence updates, call management, and channel querying.
|
|
1054
|
+
*
|
|
1055
|
+
* It is highly recommended to instantiate this class as a Singleton via `ErmisChat.getInstance()`.
|
|
1056
|
+
*/
|
|
981
1057
|
declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics> {
|
|
982
1058
|
private static _instance?;
|
|
1059
|
+
/** A map of active channels currently tracked by the client, keyed by Channel ID. */
|
|
983
1060
|
activeChannels: {
|
|
984
1061
|
[key: string]: Channel<ErmisChatGenerics>;
|
|
985
1062
|
};
|
|
1063
|
+
/** The internal configured Axios instance used for REST API requests. */
|
|
986
1064
|
axiosInstance: AxiosInstance;
|
|
1065
|
+
/** The primary base URL for REST API communication. */
|
|
987
1066
|
baseURL?: string;
|
|
1067
|
+
/** The specific base URL for standard user-focused REST calls. */
|
|
988
1068
|
userBaseURL?: string;
|
|
1069
|
+
/** True when the SDK is executed inside a browser environment. */
|
|
989
1070
|
browser: boolean;
|
|
990
1071
|
cleaningIntervalRef?: NodeJS.Timeout;
|
|
991
1072
|
clientID?: string;
|
|
992
1073
|
apiKey: string;
|
|
993
1074
|
projectId: string;
|
|
1075
|
+
/** Internal mapped registry of event listeners. */
|
|
994
1076
|
listeners: Record<string, Array<(event: Event$1<ErmisChatGenerics>) => void>>;
|
|
995
1077
|
logger: Logger;
|
|
1078
|
+
/** Whether the client should automatically fetch missing messages upon unexpected disconnects. */
|
|
996
1079
|
recoverStateOnReconnect?: boolean;
|
|
1080
|
+
/** True when the SDK is executed in a NodeJS environment constraint. */
|
|
997
1081
|
node: boolean;
|
|
1082
|
+
/** Custom options passed during client initialization. */
|
|
998
1083
|
options: ErmisChatOptions;
|
|
999
1084
|
setUserPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
|
|
1085
|
+
/** Centralized global state orchestrating user and client metadata. */
|
|
1000
1086
|
state: ClientState<ErmisChatGenerics>;
|
|
1001
1087
|
tokenManager: TokenManager<ErmisChatGenerics>;
|
|
1088
|
+
/** The globally authenticated current user object. */
|
|
1002
1089
|
user?: UserResponse<ErmisChatGenerics>;
|
|
1003
1090
|
userAgent?: string;
|
|
1091
|
+
/** The unique ID of the current authenticated user. */
|
|
1004
1092
|
userID?: string;
|
|
1093
|
+
/** The configured WebSocket endpoint base URL for realtime subscriptions. */
|
|
1005
1094
|
wsBaseURL?: string;
|
|
1095
|
+
/** The active WebSocket connection controller. */
|
|
1006
1096
|
wsConnection: StableWSConnection<ErmisChatGenerics> | null;
|
|
1007
1097
|
wsPromise: ConnectAPIResponse<ErmisChatGenerics> | null;
|
|
1098
|
+
/** Tracks consecutive REST API failures for exponential backoff purposes. */
|
|
1008
1099
|
consecutiveFailures: number;
|
|
1009
1100
|
defaultWSTimeout: number;
|
|
1010
1101
|
private eventSource;
|
|
1102
|
+
/**
|
|
1103
|
+
* Initializes a new Ermis Chat Client instance.
|
|
1104
|
+
*
|
|
1105
|
+
* @param apiKey - Your public Ermis Network API Key.
|
|
1106
|
+
* @param projectId - Your specific Project UUID pointing to the app config.
|
|
1107
|
+
* @param baseURL - The API base endpoint assigned to your project.
|
|
1108
|
+
* @param options - Additional connection rules and configuration options.
|
|
1109
|
+
*/
|
|
1011
1110
|
constructor(apiKey: string, projectId: string, baseURL: string, options?: ErmisChatOptions);
|
|
1111
|
+
/**
|
|
1112
|
+
* Retrieves the globally registered Singleton instance of the ErmisChat client.
|
|
1113
|
+
* If the instance lacks existence, it initializes a new one.
|
|
1114
|
+
*
|
|
1115
|
+
* @param key - Your public Ermis Network API Key.
|
|
1116
|
+
* @param projectId - Your specific Project UUID.
|
|
1117
|
+
* @param baseURL - The API base endpoint.
|
|
1118
|
+
* @param options - Connection options.
|
|
1119
|
+
* @returns The shared ErmisChat client instance.
|
|
1120
|
+
*/
|
|
1012
1121
|
static getInstance<ErmisChatGenerics extends ExtendableGenerics = DefaultGenerics>(key: string, projectId: string, baseURL: string, options?: ErmisChatOptions): ErmisChat<ErmisChatGenerics>;
|
|
1013
1122
|
refreshNewToken(refresh_token: string): Promise<APIResponse>;
|
|
1014
1123
|
getAuthType(): string;
|
|
1015
1124
|
setBaseURL(baseURL: string): void;
|
|
1016
1125
|
getExternalAuthToken(user: UserResponse<ErmisChatGenerics>, token: string | null): Promise<any>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Connects a user to the Ermis network and establishes the WebSocket connection.
|
|
1128
|
+
* This is the primary method to authenticate your client application.
|
|
1129
|
+
*
|
|
1130
|
+
* @param user - The User object containing `id`, `name`, and optional `avatar`.
|
|
1131
|
+
* @param userTokenOrProvider - The JWT token or an async token provider function.
|
|
1132
|
+
* @param extenal_auth - Set to `true` to use your custom backend external authentication flow.
|
|
1133
|
+
* @returns A promise resolving to the API connection response once authenticated.
|
|
1134
|
+
*/
|
|
1017
1135
|
connectUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1018
1136
|
setUser: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null, extenal_auth?: boolean) => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1019
1137
|
_setToken: (user: UserResponse<ErmisChatGenerics>, userTokenOrProvider: string | null) => Promise<void>;
|
|
@@ -1021,15 +1139,44 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1021
1139
|
closeConnection: (timeout?: number) => Promise<void>;
|
|
1022
1140
|
openConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1023
1141
|
_setupConnection: () => Promise<void | ConnectionOpen<ErmisChatGenerics>>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Gracefully disconnects the current user, terminates the WebSocket connection,
|
|
1144
|
+
* cleans up listeners, and resets the client's internal references.
|
|
1145
|
+
*
|
|
1146
|
+
* @param timeout - Optional timeout in milliseconds before forcing the disconnect.
|
|
1147
|
+
*/
|
|
1024
1148
|
disconnectUser: (timeout?: number) => Promise<void>;
|
|
1025
1149
|
disconnect: (timeout?: number) => Promise<void>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Attaches an event listener to the client connection.
|
|
1152
|
+
* Listeners can be scoped to specific event types (e.g. `message.new`) or listen to `all` events.
|
|
1153
|
+
*
|
|
1154
|
+
* @param callback - The handler invoked when the event is emitted.
|
|
1155
|
+
* @returns An object containing an `unsubscribe` method to detach the listener.
|
|
1156
|
+
*/
|
|
1026
1157
|
on(callback: EventHandler<ErmisChatGenerics>): {
|
|
1027
1158
|
unsubscribe: () => void;
|
|
1028
1159
|
};
|
|
1160
|
+
/**
|
|
1161
|
+
* Attaches an event listener filtered by a specific event type.
|
|
1162
|
+
*
|
|
1163
|
+
* @param eventType - The specific event name to listen for (e.g., `'notification.message_new'`).
|
|
1164
|
+
* @param callback - The handler invoked when the event is emitted.
|
|
1165
|
+
* @returns An object containing an `unsubscribe` method to detach the listener.
|
|
1166
|
+
*/
|
|
1029
1167
|
on(eventType: string, callback: EventHandler<ErmisChatGenerics>): {
|
|
1030
1168
|
unsubscribe: () => void;
|
|
1031
1169
|
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Detaches a previously registered general event listener.
|
|
1172
|
+
* @param callback - The original handler reference to remove.
|
|
1173
|
+
*/
|
|
1032
1174
|
off(callback: EventHandler<ErmisChatGenerics>): void;
|
|
1175
|
+
/**
|
|
1176
|
+
* Detaches a previously registered event listener scoped to a specific event type.
|
|
1177
|
+
* @param eventType - The specific event name.
|
|
1178
|
+
* @param callback - The original handler reference to remove.
|
|
1179
|
+
*/
|
|
1033
1180
|
off(eventType: string, callback: EventHandler<ErmisChatGenerics>): void;
|
|
1034
1181
|
_logApiRequest(type: string, url: string, data: unknown, config: AxiosRequestConfig & {
|
|
1035
1182
|
config?: AxiosRequestConfig & {
|
|
@@ -1075,6 +1222,16 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1075
1222
|
avatar: string;
|
|
1076
1223
|
}>;
|
|
1077
1224
|
updateProfile(name: string, about_me: string): Promise<UserResponse<ErmisChatGenerics>>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Queries the API for a list of channels based on provided search filters and sort conditions.
|
|
1227
|
+
* Also hydrates these channels into the local SDK state memory.
|
|
1228
|
+
*
|
|
1229
|
+
* @param filterConditions - Specific criteria to filter channels (e.g. `{ type: 'messaging', members: { $in: ['user1'] } }`).
|
|
1230
|
+
* @param sort - The sorting hierarchy applied to the channel results.
|
|
1231
|
+
* @param options - Pagination and message limit parameters.
|
|
1232
|
+
* @param stateOptions - Defines whether to skip state initialization or offline usage.
|
|
1233
|
+
* @returns An array of hydrated and locally manageable `Channel` objects.
|
|
1234
|
+
*/
|
|
1078
1235
|
queryChannels(filterConditions: ChannelFilters, sort?: ChannelSort, options?: {
|
|
1079
1236
|
message_limit?: number;
|
|
1080
1237
|
}, stateOptions?: ChannelStateOptions): Promise<Channel<ErmisChatGenerics>[]>;
|
|
@@ -1085,7 +1242,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
|
|
|
1085
1242
|
searchPublicChannel(search_term: string, offset?: number, limit?: number): Promise<APIResponse>;
|
|
1086
1243
|
pinChannel(channelType: string, channelId: string): Promise<APIResponse>;
|
|
1087
1244
|
unpinChannel(channelType: string, channelId: string): Promise<APIResponse>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Creates or instantiates an interactive `Channel` object locally based on type and custom data.
|
|
1247
|
+
* This does NOT immediately ping the API unless `channel.watch()` or `channel.create()` is subsequently called.
|
|
1248
|
+
*
|
|
1249
|
+
* @param type - The strict channel type descriptor (e.g., `'messaging'`, `'team'`, `'livestream'`).
|
|
1250
|
+
* @param custom - Initial metadata or specific members to include in the channel.
|
|
1251
|
+
* @returns A newly instantiated `Channel` object.
|
|
1252
|
+
*/
|
|
1088
1253
|
channel(type: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Creates or instantiates an interactive `Channel` object locally using a specific ID.
|
|
1256
|
+
*
|
|
1257
|
+
* @param type - The strict channel type descriptor.
|
|
1258
|
+
* @param id - The unique identifer (UUID / slug) for the channel.
|
|
1259
|
+
* @param custom - Initial metadata or specific members to include in the channel.
|
|
1260
|
+
* @returns A newly instantiated `Channel` object.
|
|
1261
|
+
*/
|
|
1089
1262
|
channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
|
|
1090
1263
|
getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
|
|
1091
1264
|
getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
|