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

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.
@@ -938,10 +938,9 @@ var Channel = class {
938
938
  };
939
939
  this.state.addMessageSorted(optimisticMessage);
940
940
  try {
941
- return await this.getClient().post(
942
- this._channelURL() + "/message",
943
- { message: { ...message } }
944
- );
941
+ return await this.getClient().post(this._channelURL() + "/message", {
942
+ message: { ...message }
943
+ });
945
944
  } catch (error) {
946
945
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
947
946
  const statusToSet = isOfflineError ? "failed_offline" : "error";
@@ -966,10 +965,9 @@ var Channel = class {
966
965
  messagePayload.show_in_channel = stateMsg.show_in_channel;
967
966
  }
968
967
  try {
969
- return await this.getClient().post(
970
- this._channelURL() + "/message",
971
- { message: messagePayload }
972
- );
968
+ return await this.getClient().post(this._channelURL() + "/message", {
969
+ message: messagePayload
970
+ });
973
971
  } catch (error) {
974
972
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
975
973
  this.state.updateMessageStatus(messageId, isOfflineError ? "failed_offline" : "error");
@@ -1036,9 +1034,7 @@ var Channel = class {
1036
1034
  return file;
1037
1035
  });
1038
1036
  const uploadResults = await Promise.allSettled(
1039
- processedFiles.map(
1040
- (file) => this.sendFile(file, file.name, file.type)
1041
- )
1037
+ processedFiles.map((file) => this.sendFile(file, file.name, file.type))
1042
1038
  );
1043
1039
  const thumbUrls = /* @__PURE__ */ new Map();
1044
1040
  const thumbPromises = [];
@@ -1050,11 +1046,7 @@ var Channel = class {
1050
1046
  try {
1051
1047
  const thumbBlob = await this.getThumbBlobVideo(files[i]);
1052
1048
  if (thumbBlob) {
1053
- const thumbFile = new File(
1054
- [thumbBlob],
1055
- `thumb_${processedFiles[i].name}.jpg`,
1056
- { type: "image/jpeg" }
1057
- );
1049
+ const thumbFile = new File([thumbBlob], `thumb_${processedFiles[i].name}.jpg`, { type: "image/jpeg" });
1058
1050
  const thumbResp = await this.sendFile(thumbFile, thumbFile.name, "image/jpeg");
1059
1051
  thumbUrls.set(i, thumbResp.file);
1060
1052
  }
@@ -1072,9 +1064,7 @@ var Channel = class {
1072
1064
  const uploadedUrl = result.value.file;
1073
1065
  const thumbUrl = thumbUrls.get(i);
1074
1066
  const voiceMeta = options?.voiceMetadata?.get(i);
1075
- attachments.push(
1076
- buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta)
1077
- );
1067
+ attachments.push(buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta));
1078
1068
  } else {
1079
1069
  failedFiles.push({
1080
1070
  file: files[i],
@@ -1422,7 +1412,7 @@ var Channel = class {
1422
1412
  if (this.id) {
1423
1413
  queryURL += `/${this.id}`;
1424
1414
  } else {
1425
- if (this.type === "team") {
1415
+ if (this.type === "team" || this.type === "meeting") {
1426
1416
  const uuid = randomId();
1427
1417
  this.id = `${project_id}:${uuid}`;
1428
1418
  queryURL += `/${this.id}`;
@@ -3713,6 +3703,47 @@ var ErmisChat = class _ErmisChat {
3713
3703
  this.activeChannels[channel.cid] = channel;
3714
3704
  return channel;
3715
3705
  };
3706
+ /**
3707
+ * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
3708
+ * Consumers can customize the `name` field. `members` and `public` fields are constrained.
3709
+ *
3710
+ * @param name - The custom name for the meeting channel.
3711
+ * @returns A promise that resolves to the created `Channel` object.
3712
+ */
3713
+ async createMeetingChannel(name) {
3714
+ if (!this.userID) {
3715
+ throw Error("Call connectUser before creating a channel");
3716
+ }
3717
+ const payload = {
3718
+ name: name || `Meeting Public - ${(/* @__PURE__ */ new Date()).toISOString()}`,
3719
+ members: [this.userID],
3720
+ public: true
3721
+ };
3722
+ const meetingChannel = this.channel("meeting", payload);
3723
+ await meetingChannel.create();
3724
+ return meetingChannel;
3725
+ }
3726
+ /**
3727
+ * Joins a `meeting` channel.
3728
+ * It queries/watches the channel to see if caller is already a member.
3729
+ * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
3730
+ *
3731
+ * @param channelId - The ID of the meeting channel to join.
3732
+ * @returns A promise that resolves to the joined `Channel` object.
3733
+ */
3734
+ async joinMeetingChannel(channelId) {
3735
+ if (!this.userID) {
3736
+ throw Error("Call connectUser before joining a channel");
3737
+ }
3738
+ const meetingChannel = this.channel("meeting", channelId);
3739
+ await meetingChannel.watch();
3740
+ const isMember = meetingChannel.state.members && meetingChannel.state.members[this.userID];
3741
+ if (!isMember) {
3742
+ await meetingChannel.acceptInvite("join");
3743
+ await meetingChannel.watch();
3744
+ }
3745
+ return meetingChannel;
3746
+ }
3716
3747
  _normalizeExpiration(timeoutOrExpirationDate) {
3717
3748
  let pinExpires = null;
3718
3749
  if (typeof timeoutOrExpirationDate === "number") {
@@ -3727,7 +3758,7 @@ var ErmisChat = class _ErmisChat {
3727
3758
  return pinExpires;
3728
3759
  }
3729
3760
  getUserAgent() {
3730
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.5"}`;
3761
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
3731
3762
  }
3732
3763
  setUserAgent(userAgent) {
3733
3764
  this.userAgent = userAgent;
@@ -7085,7 +7116,7 @@ var ErmisAuthProvider = class {
7085
7116
  return data;
7086
7117
  }
7087
7118
  getUserAgent() {
7088
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.5"}`;
7119
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
7089
7120
  }
7090
7121
  setUserAgent(userAgent) {
7091
7122
  this.userAgent = userAgent;