stream-chat 8.25.1 → 8.26.0

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.
@@ -503,6 +503,111 @@ var ChannelState = /*#__PURE__*/function () {
503
503
  };
504
504
  });
505
505
 
506
+ _defineProperty(this, "updatePollVote", function (pollVote, poll, messageId) {
507
+ var message = _this.findMessage(messageId);
508
+
509
+ if (!message) return;
510
+ if (message.poll_id !== pollVote.poll_id) return;
511
+
512
+ var updatedPoll = _objectSpread$7({}, poll);
513
+
514
+ var ownVotes = _toConsumableArray(message.poll.own_votes || []);
515
+
516
+ if (pollVote.user_id === _this._channel.getClient().userID) {
517
+ if (pollVote.option_id && poll.enforce_unique_vote) {
518
+ // remove all previous votes where option_id is not empty
519
+ ownVotes = ownVotes.filter(function (vote) {
520
+ return !vote.option_id;
521
+ });
522
+ } else if (pollVote.answer_text) {
523
+ // remove all previous votes where option_id is empty
524
+ ownVotes = ownVotes.filter(function (vote) {
525
+ return vote.answer_text;
526
+ });
527
+ }
528
+
529
+ ownVotes.push(pollVote);
530
+ }
531
+
532
+ updatedPoll.own_votes = ownVotes;
533
+
534
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
535
+ poll: updatedPoll
536
+ });
537
+
538
+ _this.addMessageSorted(newMessage, false, false);
539
+ });
540
+
541
+ _defineProperty(this, "addPollVote", function (pollVote, poll, messageId) {
542
+ var message = _this.findMessage(messageId);
543
+
544
+ if (!message) return;
545
+ if (message.poll_id !== pollVote.poll_id) return;
546
+
547
+ var updatedPoll = _objectSpread$7({}, poll);
548
+
549
+ var ownVotes = _toConsumableArray(message.poll.own_votes || []);
550
+
551
+ if (pollVote.user_id === _this._channel.getClient().userID) {
552
+ ownVotes.push(pollVote);
553
+ }
554
+
555
+ updatedPoll.own_votes = ownVotes;
556
+
557
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
558
+ poll: updatedPoll
559
+ });
560
+
561
+ _this.addMessageSorted(newMessage, false, false);
562
+ });
563
+
564
+ _defineProperty(this, "removePollVote", function (pollVote, poll, messageId) {
565
+ var message = _this.findMessage(messageId);
566
+
567
+ if (!message) return;
568
+ if (message.poll_id !== pollVote.poll_id) return;
569
+
570
+ var updatedPoll = _objectSpread$7({}, poll);
571
+
572
+ var ownVotes = _toConsumableArray(message.poll.own_votes || []);
573
+
574
+ if (pollVote.user_id === _this._channel.getClient().userID) {
575
+ var index = ownVotes.findIndex(function (vote) {
576
+ return vote.option_id === pollVote.option_id;
577
+ });
578
+
579
+ if (index > -1) {
580
+ ownVotes.splice(index, 1);
581
+ }
582
+ }
583
+
584
+ updatedPoll.own_votes = ownVotes;
585
+
586
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
587
+ poll: updatedPoll
588
+ });
589
+
590
+ _this.addMessageSorted(newMessage, false, false);
591
+ });
592
+
593
+ _defineProperty(this, "updatePoll", function (poll, messageId) {
594
+ var _message$poll;
595
+
596
+ var message = _this.findMessage(messageId);
597
+
598
+ if (!message) return;
599
+
600
+ var updatedPoll = _objectSpread$7(_objectSpread$7({}, poll), {}, {
601
+ own_votes: _toConsumableArray(((_message$poll = message.poll) === null || _message$poll === void 0 ? void 0 : _message$poll.own_votes) || [])
602
+ });
603
+
604
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
605
+ poll: updatedPoll
606
+ });
607
+
608
+ _this.addMessageSorted(newMessage, false, false);
609
+ });
610
+
506
611
  _defineProperty(this, "updateUserMessages", function (user) {
507
612
  var _updateUserMessages = function _updateUserMessages(messages, user) {
508
613
  for (var i = 0; i < messages.length; i++) {
@@ -3607,6 +3712,69 @@ var Channel = /*#__PURE__*/function () {
3607
3712
 
3608
3713
  return createCall;
3609
3714
  }()
3715
+ /**
3716
+ * Cast or cancel one or more votes on a poll
3717
+ * @param pollId string The poll id
3718
+ * @param votes PollVoteData[] The votes that will be casted (or canceled in case of an empty array)
3719
+ * @returns {APIResponse & PollVoteResponse} The poll votes
3720
+ */
3721
+
3722
+ }, {
3723
+ key: "vote",
3724
+ value: function () {
3725
+ var _vote2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40(messageId, pollId, _vote) {
3726
+ return _regeneratorRuntime.wrap(function _callee40$(_context40) {
3727
+ while (1) {
3728
+ switch (_context40.prev = _context40.next) {
3729
+ case 0:
3730
+ _context40.next = 2;
3731
+ return this.getClient().castPollVote(messageId, pollId, _vote);
3732
+
3733
+ case 2:
3734
+ return _context40.abrupt("return", _context40.sent);
3735
+
3736
+ case 3:
3737
+ case "end":
3738
+ return _context40.stop();
3739
+ }
3740
+ }
3741
+ }, _callee40, this);
3742
+ }));
3743
+
3744
+ function vote(_x42, _x43, _x44) {
3745
+ return _vote2.apply(this, arguments);
3746
+ }
3747
+
3748
+ return vote;
3749
+ }()
3750
+ }, {
3751
+ key: "removeVote",
3752
+ value: function () {
3753
+ var _removeVote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(messageId, pollId, voteId) {
3754
+ return _regeneratorRuntime.wrap(function _callee41$(_context41) {
3755
+ while (1) {
3756
+ switch (_context41.prev = _context41.next) {
3757
+ case 0:
3758
+ _context41.next = 2;
3759
+ return this.getClient().removePollVote(messageId, pollId, voteId);
3760
+
3761
+ case 2:
3762
+ return _context41.abrupt("return", _context41.sent);
3763
+
3764
+ case 3:
3765
+ case "end":
3766
+ return _context41.stop();
3767
+ }
3768
+ }
3769
+ }, _callee41, this);
3770
+ }));
3771
+
3772
+ function removeVote(_x45, _x46, _x47) {
3773
+ return _removeVote.apply(this, arguments);
3774
+ }
3775
+
3776
+ return removeVote;
3777
+ }()
3610
3778
  /**
3611
3779
  * on - Listen to events on this channel.
3612
3780
  *
@@ -3905,6 +4073,49 @@ var Channel = /*#__PURE__*/function () {
3905
4073
 
3906
4074
  break;
3907
4075
 
4076
+ case 'poll.updated':
4077
+ if (event.poll) {
4078
+ var _event$message;
4079
+
4080
+ channelState.updatePoll(event.poll, ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.id) || '');
4081
+ }
4082
+
4083
+ break;
4084
+
4085
+ case 'poll.vote_casted':
4086
+ if (event.poll_vote && event.poll) {
4087
+ var _event$message2;
4088
+
4089
+ channelState.addPollVote(event.poll_vote, event.poll, ((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.id) || '');
4090
+ }
4091
+
4092
+ break;
4093
+
4094
+ case 'poll.vote_changed':
4095
+ if (event.poll_vote && event.poll) {
4096
+ var _event$message3;
4097
+
4098
+ channelState.updatePollVote(event.poll_vote, event.poll, ((_event$message3 = event.message) === null || _event$message3 === void 0 ? void 0 : _event$message3.id) || '');
4099
+ }
4100
+
4101
+ break;
4102
+
4103
+ case 'poll.vote_removed':
4104
+ if (event.poll_vote && event.poll) {
4105
+ var _event$message4;
4106
+
4107
+ channelState.removePollVote(event.poll_vote, event.poll, ((_event$message4 = event.message) === null || _event$message4 === void 0 ? void 0 : _event$message4.id) || '');
4108
+ }
4109
+
4110
+ break;
4111
+
4112
+ case 'poll.closed':
4113
+ if (event.message) {
4114
+ channelState.addMessageSorted(event.message, false, false);
4115
+ }
4116
+
4117
+ break;
4118
+
3908
4119
  case 'reaction.new':
3909
4120
  if (event.message && event.reaction) {
3910
4121
  event.message = channelState.addReaction(event.reaction, event.message);
@@ -6586,8 +6797,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
6586
6797
  DeleteUserOptions specifies a collection of one or more `user_ids` to be deleted.
6587
6798
 
6588
6799
  `user`:
6589
- - soft: marks user as deleted and retains all user data
6590
- - pruning: marks user as deleted and nullifies user information
6800
+ - soft: marks user as deleted and retains all user data
6801
+ - pruning: marks user as deleted and nullifies user information
6591
6802
  - hard: deletes user completely - this requires hard option for messages and conversation as well
6592
6803
  `conversations`:
6593
6804
  - soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled)
@@ -6626,6 +6837,14 @@ var ErrorFromResponse = /*#__PURE__*/function (_Error) {
6626
6837
 
6627
6838
  return ErrorFromResponse;
6628
6839
  }( /*#__PURE__*/_wrapNativeSuper(Error));
6840
+ var VotingVisibility;
6841
+
6842
+ (function (VotingVisibility) {
6843
+ VotingVisibility["anonymous"] = "anonymous";
6844
+ VotingVisibility["public"] = "public";
6845
+ })(VotingVisibility || (VotingVisibility = {}));
6846
+
6847
+ var _excluded$1 = ["parent_message_id", "parent_message", "latest_replies", "thread_participants", "reply_count", "channel", "read"];
6629
6848
 
6630
6849
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6631
6850
 
@@ -6637,6 +6856,7 @@ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o
6637
6856
 
6638
6857
  function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6639
6858
  var Thread = /*#__PURE__*/function () {
6859
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6640
6860
  function Thread(client, t) {
6641
6861
  _classCallCheck(this, Thread);
6642
6862
 
@@ -6658,17 +6878,28 @@ var Thread = /*#__PURE__*/function () {
6658
6878
 
6659
6879
  _defineProperty(this, "read", {});
6660
6880
 
6661
- this.id = t.parent_message.id;
6662
- this.message = formatMessage(t.parent_message);
6663
- this.latestReplies = t.latest_replies.map(formatMessage);
6664
- this.participants = t.thread_participants;
6665
- this.replyCount = t.reply_count;
6666
- this.channel = t.channel;
6881
+ _defineProperty(this, "data", {});
6882
+
6883
+ var parent_message_id = t.parent_message_id,
6884
+ parent_message = t.parent_message,
6885
+ latest_replies = t.latest_replies,
6886
+ thread_participants = t.thread_participants,
6887
+ reply_count = t.reply_count,
6888
+ channel = t.channel,
6889
+ read = t.read,
6890
+ data = _objectWithoutProperties(t, _excluded$1);
6891
+
6892
+ this.id = parent_message_id;
6893
+ this.message = formatMessage(parent_message);
6894
+ this.latestReplies = latest_replies.map(formatMessage);
6895
+ this.participants = thread_participants;
6896
+ this.replyCount = reply_count;
6897
+ this.channel = channel;
6667
6898
  this._channel = client.channel(t.channel.type, t.channel.id);
6668
6899
  this._client = client;
6669
6900
 
6670
- if (t.read) {
6671
- var _iterator = _createForOfIteratorHelper$1(t.read),
6901
+ if (read) {
6902
+ var _iterator = _createForOfIteratorHelper$1(read),
6672
6903
  _step;
6673
6904
 
6674
6905
  try {
@@ -6684,6 +6915,8 @@ var Thread = /*#__PURE__*/function () {
6684
6915
  _iterator.f();
6685
6916
  }
6686
6917
  }
6918
+
6919
+ this.data = data;
6687
6920
  }
6688
6921
 
6689
6922
  _createClass(Thread, [{
@@ -11100,7 +11333,7 @@ var StreamChat = /*#__PURE__*/function () {
11100
11333
  }, {
11101
11334
  key: "getUserAgent",
11102
11335
  value: function getUserAgent() {
11103
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.25.1");
11336
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.26.0");
11104
11337
  }
11105
11338
  }, {
11106
11339
  key: "setUserAgent",
@@ -12542,6 +12775,552 @@ var StreamChat = /*#__PURE__*/function () {
12542
12775
 
12543
12776
  return commitMessage;
12544
12777
  }()
12778
+ /**
12779
+ * Creates a poll
12780
+ * @param params PollData The poll that will be created
12781
+ * @returns {APIResponse & CreatePollAPIResponse} The poll
12782
+ */
12783
+
12784
+ }, {
12785
+ key: "createPoll",
12786
+ value: function () {
12787
+ var _createPoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee94(poll) {
12788
+ return _regeneratorRuntime.wrap(function _callee94$(_context94) {
12789
+ while (1) {
12790
+ switch (_context94.prev = _context94.next) {
12791
+ case 0:
12792
+ _context94.next = 2;
12793
+ return this.post(this.baseURL + "/polls", poll);
12794
+
12795
+ case 2:
12796
+ return _context94.abrupt("return", _context94.sent);
12797
+
12798
+ case 3:
12799
+ case "end":
12800
+ return _context94.stop();
12801
+ }
12802
+ }
12803
+ }, _callee94, this);
12804
+ }));
12805
+
12806
+ function createPoll(_x129) {
12807
+ return _createPoll.apply(this, arguments);
12808
+ }
12809
+
12810
+ return createPoll;
12811
+ }()
12812
+ /**
12813
+ * Retrieves a poll
12814
+ * @param id string The poll id
12815
+ * @returns {APIResponse & GetPollAPIResponse} The poll
12816
+ */
12817
+
12818
+ }, {
12819
+ key: "getPoll",
12820
+ value: function () {
12821
+ var _getPoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee95(id, userId) {
12822
+ return _regeneratorRuntime.wrap(function _callee95$(_context95) {
12823
+ while (1) {
12824
+ switch (_context95.prev = _context95.next) {
12825
+ case 0:
12826
+ _context95.next = 2;
12827
+ return this.get(this.baseURL + "/polls/".concat(id), _objectSpread({}, userId ? {
12828
+ user_id: userId
12829
+ } : {}));
12830
+
12831
+ case 2:
12832
+ return _context95.abrupt("return", _context95.sent);
12833
+
12834
+ case 3:
12835
+ case "end":
12836
+ return _context95.stop();
12837
+ }
12838
+ }
12839
+ }, _callee95, this);
12840
+ }));
12841
+
12842
+ function getPoll(_x130, _x131) {
12843
+ return _getPoll.apply(this, arguments);
12844
+ }
12845
+
12846
+ return getPoll;
12847
+ }()
12848
+ /**
12849
+ * Updates a poll
12850
+ * @param poll PollData The poll that will be updated
12851
+ * @returns {APIResponse & PollResponse} The poll
12852
+ */
12853
+
12854
+ }, {
12855
+ key: "updatePoll",
12856
+ value: function () {
12857
+ var _updatePoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee96(poll) {
12858
+ return _regeneratorRuntime.wrap(function _callee96$(_context96) {
12859
+ while (1) {
12860
+ switch (_context96.prev = _context96.next) {
12861
+ case 0:
12862
+ _context96.next = 2;
12863
+ return this.put(this.baseURL + "/polls", poll);
12864
+
12865
+ case 2:
12866
+ return _context96.abrupt("return", _context96.sent);
12867
+
12868
+ case 3:
12869
+ case "end":
12870
+ return _context96.stop();
12871
+ }
12872
+ }
12873
+ }, _callee96, this);
12874
+ }));
12875
+
12876
+ function updatePoll(_x132) {
12877
+ return _updatePoll.apply(this, arguments);
12878
+ }
12879
+
12880
+ return updatePoll;
12881
+ }()
12882
+ /**
12883
+ * Partially updates a poll
12884
+ * @param id string The poll id
12885
+ * @param {PartialPollUpdate<StreamChatGenerics>} partialPollObject which should contain id and any of "set" or "unset" params;
12886
+ * example: {id: "44f26af5-f2be-4fa7-9dac-71cf893781de", set:{field: value}, unset:["field2"]}
12887
+ * @returns {APIResponse & UpdatePollAPIResponse} The poll
12888
+ */
12889
+
12890
+ }, {
12891
+ key: "partialUpdatePoll",
12892
+ value: function () {
12893
+ var _partialUpdatePoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(id, partialPollObject) {
12894
+ return _regeneratorRuntime.wrap(function _callee97$(_context97) {
12895
+ while (1) {
12896
+ switch (_context97.prev = _context97.next) {
12897
+ case 0:
12898
+ _context97.next = 2;
12899
+ return this.patch(this.baseURL + "/polls/".concat(id), partialPollObject);
12900
+
12901
+ case 2:
12902
+ return _context97.abrupt("return", _context97.sent);
12903
+
12904
+ case 3:
12905
+ case "end":
12906
+ return _context97.stop();
12907
+ }
12908
+ }
12909
+ }, _callee97, this);
12910
+ }));
12911
+
12912
+ function partialUpdatePoll(_x133, _x134) {
12913
+ return _partialUpdatePoll.apply(this, arguments);
12914
+ }
12915
+
12916
+ return partialUpdatePoll;
12917
+ }()
12918
+ /**
12919
+ * Delete a poll
12920
+ * @param id string The poll id
12921
+ * @param userId string The user id (only serverside)
12922
+ * @returns
12923
+ */
12924
+
12925
+ }, {
12926
+ key: "deletePoll",
12927
+ value: function () {
12928
+ var _deletePoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee98(id, userId) {
12929
+ return _regeneratorRuntime.wrap(function _callee98$(_context98) {
12930
+ while (1) {
12931
+ switch (_context98.prev = _context98.next) {
12932
+ case 0:
12933
+ _context98.next = 2;
12934
+ return this.delete(this.baseURL + "/polls/".concat(id), _objectSpread({}, userId ? {
12935
+ user_id: userId
12936
+ } : {}));
12937
+
12938
+ case 2:
12939
+ return _context98.abrupt("return", _context98.sent);
12940
+
12941
+ case 3:
12942
+ case "end":
12943
+ return _context98.stop();
12944
+ }
12945
+ }
12946
+ }, _callee98, this);
12947
+ }));
12948
+
12949
+ function deletePoll(_x135, _x136) {
12950
+ return _deletePoll.apply(this, arguments);
12951
+ }
12952
+
12953
+ return deletePoll;
12954
+ }()
12955
+ /**
12956
+ * Close a poll
12957
+ * @param id string The poll id
12958
+ * @returns {APIResponse & UpdatePollAPIResponse} The poll
12959
+ */
12960
+
12961
+ }, {
12962
+ key: "closePoll",
12963
+ value: function () {
12964
+ var _closePoll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee99(id) {
12965
+ return _regeneratorRuntime.wrap(function _callee99$(_context99) {
12966
+ while (1) {
12967
+ switch (_context99.prev = _context99.next) {
12968
+ case 0:
12969
+ return _context99.abrupt("return", this.partialUpdatePoll(id, {
12970
+ set: {
12971
+ is_closed: true
12972
+ }
12973
+ }));
12974
+
12975
+ case 1:
12976
+ case "end":
12977
+ return _context99.stop();
12978
+ }
12979
+ }
12980
+ }, _callee99, this);
12981
+ }));
12982
+
12983
+ function closePoll(_x137) {
12984
+ return _closePoll.apply(this, arguments);
12985
+ }
12986
+
12987
+ return closePoll;
12988
+ }()
12989
+ /**
12990
+ * Creates a poll option
12991
+ * @param pollId string The poll id
12992
+ * @param option PollOptionData The poll option that will be created
12993
+ * @returns {APIResponse & PollOptionResponse} The poll option
12994
+ */
12995
+
12996
+ }, {
12997
+ key: "createPollOption",
12998
+ value: function () {
12999
+ var _createPollOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee100(pollId, option) {
13000
+ return _regeneratorRuntime.wrap(function _callee100$(_context100) {
13001
+ while (1) {
13002
+ switch (_context100.prev = _context100.next) {
13003
+ case 0:
13004
+ _context100.next = 2;
13005
+ return this.post(this.baseURL + "/polls/".concat(pollId, "/options"), option);
13006
+
13007
+ case 2:
13008
+ return _context100.abrupt("return", _context100.sent);
13009
+
13010
+ case 3:
13011
+ case "end":
13012
+ return _context100.stop();
13013
+ }
13014
+ }
13015
+ }, _callee100, this);
13016
+ }));
13017
+
13018
+ function createPollOption(_x138, _x139) {
13019
+ return _createPollOption.apply(this, arguments);
13020
+ }
13021
+
13022
+ return createPollOption;
13023
+ }()
13024
+ /**
13025
+ * Retrieves a poll option
13026
+ * @param pollId string The poll id
13027
+ * @param optionId string The poll option id
13028
+ * @returns {APIResponse & PollOptionResponse} The poll option
13029
+ */
13030
+
13031
+ }, {
13032
+ key: "getPollOption",
13033
+ value: function () {
13034
+ var _getPollOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee101(pollId, optionId) {
13035
+ return _regeneratorRuntime.wrap(function _callee101$(_context101) {
13036
+ while (1) {
13037
+ switch (_context101.prev = _context101.next) {
13038
+ case 0:
13039
+ _context101.next = 2;
13040
+ return this.get(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId));
13041
+
13042
+ case 2:
13043
+ return _context101.abrupt("return", _context101.sent);
13044
+
13045
+ case 3:
13046
+ case "end":
13047
+ return _context101.stop();
13048
+ }
13049
+ }
13050
+ }, _callee101, this);
13051
+ }));
13052
+
13053
+ function getPollOption(_x140, _x141) {
13054
+ return _getPollOption.apply(this, arguments);
13055
+ }
13056
+
13057
+ return getPollOption;
13058
+ }()
13059
+ /**
13060
+ * Updates a poll option
13061
+ * @param pollId string The poll id
13062
+ * @param option PollOptionData The poll option that will be updated
13063
+ * @returns
13064
+ */
13065
+
13066
+ }, {
13067
+ key: "updatePollOption",
13068
+ value: function () {
13069
+ var _updatePollOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee102(pollId, option) {
13070
+ return _regeneratorRuntime.wrap(function _callee102$(_context102) {
13071
+ while (1) {
13072
+ switch (_context102.prev = _context102.next) {
13073
+ case 0:
13074
+ _context102.next = 2;
13075
+ return this.put(this.baseURL + "/polls/".concat(pollId, "/options"), option);
13076
+
13077
+ case 2:
13078
+ return _context102.abrupt("return", _context102.sent);
13079
+
13080
+ case 3:
13081
+ case "end":
13082
+ return _context102.stop();
13083
+ }
13084
+ }
13085
+ }, _callee102, this);
13086
+ }));
13087
+
13088
+ function updatePollOption(_x142, _x143) {
13089
+ return _updatePollOption.apply(this, arguments);
13090
+ }
13091
+
13092
+ return updatePollOption;
13093
+ }()
13094
+ /**
13095
+ * Delete a poll option
13096
+ * @param pollId string The poll id
13097
+ * @param optionId string The poll option id
13098
+ * @returns {APIResponse} The poll option
13099
+ */
13100
+
13101
+ }, {
13102
+ key: "deletePollOption",
13103
+ value: function () {
13104
+ var _deletePollOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee103(pollId, optionId) {
13105
+ return _regeneratorRuntime.wrap(function _callee103$(_context103) {
13106
+ while (1) {
13107
+ switch (_context103.prev = _context103.next) {
13108
+ case 0:
13109
+ _context103.next = 2;
13110
+ return this.delete(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId));
13111
+
13112
+ case 2:
13113
+ return _context103.abrupt("return", _context103.sent);
13114
+
13115
+ case 3:
13116
+ case "end":
13117
+ return _context103.stop();
13118
+ }
13119
+ }
13120
+ }, _callee103, this);
13121
+ }));
13122
+
13123
+ function deletePollOption(_x144, _x145) {
13124
+ return _deletePollOption.apply(this, arguments);
13125
+ }
13126
+
13127
+ return deletePollOption;
13128
+ }()
13129
+ /**
13130
+ * Cast vote on a poll
13131
+ * @param messageId string The message id
13132
+ * @param pollId string The poll id
13133
+ * @param vote PollVoteData The vote that will be casted
13134
+ * @returns {APIResponse & CastVoteAPIResponse} The poll vote
13135
+ */
13136
+
13137
+ }, {
13138
+ key: "castPollVote",
13139
+ value: function () {
13140
+ var _castPollVote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee104(messageId, pollId, vote) {
13141
+ var options,
13142
+ _args104 = arguments;
13143
+ return _regeneratorRuntime.wrap(function _callee104$(_context104) {
13144
+ while (1) {
13145
+ switch (_context104.prev = _context104.next) {
13146
+ case 0:
13147
+ options = _args104.length > 3 && _args104[3] !== undefined ? _args104[3] : {};
13148
+ _context104.next = 3;
13149
+ return this.post(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote"), _objectSpread({
13150
+ vote: vote
13151
+ }, options));
13152
+
13153
+ case 3:
13154
+ return _context104.abrupt("return", _context104.sent);
13155
+
13156
+ case 4:
13157
+ case "end":
13158
+ return _context104.stop();
13159
+ }
13160
+ }
13161
+ }, _callee104, this);
13162
+ }));
13163
+
13164
+ function castPollVote(_x146, _x147, _x148) {
13165
+ return _castPollVote.apply(this, arguments);
13166
+ }
13167
+
13168
+ return castPollVote;
13169
+ }()
13170
+ /**
13171
+ * Add a poll answer
13172
+ * @param messageId string The message id
13173
+ * @param pollId string The poll id
13174
+ * @param answerText string The answer text
13175
+ */
13176
+
13177
+ }, {
13178
+ key: "addPollAnswer",
13179
+ value: function () {
13180
+ var _addPollAnswer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee105(messageId, pollId, answerText) {
13181
+ return _regeneratorRuntime.wrap(function _callee105$(_context105) {
13182
+ while (1) {
13183
+ switch (_context105.prev = _context105.next) {
13184
+ case 0:
13185
+ return _context105.abrupt("return", this.castPollVote(messageId, pollId, {
13186
+ answer_text: answerText
13187
+ }));
13188
+
13189
+ case 1:
13190
+ case "end":
13191
+ return _context105.stop();
13192
+ }
13193
+ }
13194
+ }, _callee105, this);
13195
+ }));
13196
+
13197
+ function addPollAnswer(_x149, _x150, _x151) {
13198
+ return _addPollAnswer.apply(this, arguments);
13199
+ }
13200
+
13201
+ return addPollAnswer;
13202
+ }()
13203
+ }, {
13204
+ key: "removePollVote",
13205
+ value: function () {
13206
+ var _removePollVote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee106(messageId, pollId, voteId) {
13207
+ return _regeneratorRuntime.wrap(function _callee106$(_context106) {
13208
+ while (1) {
13209
+ switch (_context106.prev = _context106.next) {
13210
+ case 0:
13211
+ _context106.next = 2;
13212
+ return this.delete(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote/").concat(voteId));
13213
+
13214
+ case 2:
13215
+ return _context106.abrupt("return", _context106.sent);
13216
+
13217
+ case 3:
13218
+ case "end":
13219
+ return _context106.stop();
13220
+ }
13221
+ }
13222
+ }, _callee106, this);
13223
+ }));
13224
+
13225
+ function removePollVote(_x152, _x153, _x154) {
13226
+ return _removePollVote.apply(this, arguments);
13227
+ }
13228
+
13229
+ return removePollVote;
13230
+ }()
13231
+ /**
13232
+ * Queries polls
13233
+ * @param filter
13234
+ * @param sort
13235
+ * @param options Option object, {limit: 10, offset:0}
13236
+ * @returns {APIResponse & QueryPollsResponse} The polls
13237
+ */
13238
+
13239
+ }, {
13240
+ key: "queryPolls",
13241
+ value: function () {
13242
+ var _queryPolls = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee107() {
13243
+ var filter,
13244
+ sort,
13245
+ options,
13246
+ _args107 = arguments;
13247
+ return _regeneratorRuntime.wrap(function _callee107$(_context107) {
13248
+ while (1) {
13249
+ switch (_context107.prev = _context107.next) {
13250
+ case 0:
13251
+ filter = _args107.length > 0 && _args107[0] !== undefined ? _args107[0] : {};
13252
+ sort = _args107.length > 1 && _args107[1] !== undefined ? _args107[1] : [];
13253
+ options = _args107.length > 2 && _args107[2] !== undefined ? _args107[2] : {};
13254
+ _context107.next = 5;
13255
+ return this.post(this.baseURL + '/polls/query', _objectSpread({
13256
+ filter: filter,
13257
+ sort: normalizeQuerySort(sort)
13258
+ }, options));
13259
+
13260
+ case 5:
13261
+ return _context107.abrupt("return", _context107.sent);
13262
+
13263
+ case 6:
13264
+ case "end":
13265
+ return _context107.stop();
13266
+ }
13267
+ }
13268
+ }, _callee107, this);
13269
+ }));
13270
+
13271
+ function queryPolls() {
13272
+ return _queryPolls.apply(this, arguments);
13273
+ }
13274
+
13275
+ return queryPolls;
13276
+ }()
13277
+ /**
13278
+ * Queries poll votes
13279
+ * @param pollId
13280
+ * @param filter
13281
+ * @param sort
13282
+ * @param options Option object, {limit: 10, offset:0}
13283
+ * @returns {APIResponse & PollVotesAPIResponse} The poll votes
13284
+ */
13285
+
13286
+ }, {
13287
+ key: "queryPollVotes",
13288
+ value: function () {
13289
+ var _queryPollVotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee108(pollId) {
13290
+ var filter,
13291
+ sort,
13292
+ options,
13293
+ _args108 = arguments;
13294
+ return _regeneratorRuntime.wrap(function _callee108$(_context108) {
13295
+ while (1) {
13296
+ switch (_context108.prev = _context108.next) {
13297
+ case 0:
13298
+ filter = _args108.length > 1 && _args108[1] !== undefined ? _args108[1] : {};
13299
+ sort = _args108.length > 2 && _args108[2] !== undefined ? _args108[2] : [];
13300
+ options = _args108.length > 3 && _args108[3] !== undefined ? _args108[3] : {};
13301
+ _context108.next = 5;
13302
+ return this.post(this.baseURL + "/polls/".concat(pollId, "/votes"), _objectSpread({
13303
+ filter: filter,
13304
+ sort: normalizeQuerySort(sort)
13305
+ }, options));
13306
+
13307
+ case 5:
13308
+ return _context108.abrupt("return", _context108.sent);
13309
+
13310
+ case 6:
13311
+ case "end":
13312
+ return _context108.stop();
13313
+ }
13314
+ }
13315
+ }, _callee108, this);
13316
+ }));
13317
+
13318
+ function queryPollVotes(_x155) {
13319
+ return _queryPollVotes.apply(this, arguments);
13320
+ }
13321
+
13322
+ return queryPollVotes;
13323
+ }()
12545
13324
  }], [{
12546
13325
  key: "getInstance",
12547
13326
  value: function getInstance(key, secretOrOptions, options) {
@@ -12594,6 +13373,11 @@ var EVENT_MAP = {
12594
13373
  'notification.mutes_updated': true,
12595
13374
  'notification.removed_from_channel': true,
12596
13375
  'notification.thread_message_new': true,
13376
+ 'poll.closed': true,
13377
+ 'poll.updated': true,
13378
+ 'poll.vote_casted': true,
13379
+ 'poll.vote_changed': true,
13380
+ 'poll.vote_removed': true,
12597
13381
  'reaction.deleted': true,
12598
13382
  'reaction.new': true,
12599
13383
  'reaction.updated': true,
@@ -12689,5 +13473,5 @@ var BuiltinPermissions = {
12689
13473
  UseFrozenChannel: 'Send messages and reactions to frozen channels'
12690
13474
  };
12691
13475
 
12692
- export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, Segment, StableWSConnection, StreamChat, Thread, TokenManager, UserFromToken, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, formatMessage, isOwnUser, logChatPromiseExecution, postInsights };
13476
+ export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, Segment, StableWSConnection, StreamChat, Thread, TokenManager, UserFromToken, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, formatMessage, isOwnUser, logChatPromiseExecution, postInsights };
12693
13477
  //# sourceMappingURL=browser.es.js.map