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.
package/dist/browser.js CHANGED
@@ -528,6 +528,111 @@ var ChannelState = /*#__PURE__*/function () {
528
528
  };
529
529
  });
530
530
 
531
+ _defineProperty__default['default'](this, "updatePollVote", function (pollVote, poll, messageId) {
532
+ var message = _this.findMessage(messageId);
533
+
534
+ if (!message) return;
535
+ if (message.poll_id !== pollVote.poll_id) return;
536
+
537
+ var updatedPoll = _objectSpread$7({}, poll);
538
+
539
+ var ownVotes = _toConsumableArray__default['default'](message.poll.own_votes || []);
540
+
541
+ if (pollVote.user_id === _this._channel.getClient().userID) {
542
+ if (pollVote.option_id && poll.enforce_unique_vote) {
543
+ // remove all previous votes where option_id is not empty
544
+ ownVotes = ownVotes.filter(function (vote) {
545
+ return !vote.option_id;
546
+ });
547
+ } else if (pollVote.answer_text) {
548
+ // remove all previous votes where option_id is empty
549
+ ownVotes = ownVotes.filter(function (vote) {
550
+ return vote.answer_text;
551
+ });
552
+ }
553
+
554
+ ownVotes.push(pollVote);
555
+ }
556
+
557
+ updatedPoll.own_votes = ownVotes;
558
+
559
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
560
+ poll: updatedPoll
561
+ });
562
+
563
+ _this.addMessageSorted(newMessage, false, false);
564
+ });
565
+
566
+ _defineProperty__default['default'](this, "addPollVote", function (pollVote, poll, messageId) {
567
+ var message = _this.findMessage(messageId);
568
+
569
+ if (!message) return;
570
+ if (message.poll_id !== pollVote.poll_id) return;
571
+
572
+ var updatedPoll = _objectSpread$7({}, poll);
573
+
574
+ var ownVotes = _toConsumableArray__default['default'](message.poll.own_votes || []);
575
+
576
+ if (pollVote.user_id === _this._channel.getClient().userID) {
577
+ ownVotes.push(pollVote);
578
+ }
579
+
580
+ updatedPoll.own_votes = ownVotes;
581
+
582
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
583
+ poll: updatedPoll
584
+ });
585
+
586
+ _this.addMessageSorted(newMessage, false, false);
587
+ });
588
+
589
+ _defineProperty__default['default'](this, "removePollVote", function (pollVote, poll, messageId) {
590
+ var message = _this.findMessage(messageId);
591
+
592
+ if (!message) return;
593
+ if (message.poll_id !== pollVote.poll_id) return;
594
+
595
+ var updatedPoll = _objectSpread$7({}, poll);
596
+
597
+ var ownVotes = _toConsumableArray__default['default'](message.poll.own_votes || []);
598
+
599
+ if (pollVote.user_id === _this._channel.getClient().userID) {
600
+ var index = ownVotes.findIndex(function (vote) {
601
+ return vote.option_id === pollVote.option_id;
602
+ });
603
+
604
+ if (index > -1) {
605
+ ownVotes.splice(index, 1);
606
+ }
607
+ }
608
+
609
+ updatedPoll.own_votes = ownVotes;
610
+
611
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
612
+ poll: updatedPoll
613
+ });
614
+
615
+ _this.addMessageSorted(newMessage, false, false);
616
+ });
617
+
618
+ _defineProperty__default['default'](this, "updatePoll", function (poll, messageId) {
619
+ var _message$poll;
620
+
621
+ var message = _this.findMessage(messageId);
622
+
623
+ if (!message) return;
624
+
625
+ var updatedPoll = _objectSpread$7(_objectSpread$7({}, poll), {}, {
626
+ own_votes: _toConsumableArray__default['default'](((_message$poll = message.poll) === null || _message$poll === void 0 ? void 0 : _message$poll.own_votes) || [])
627
+ });
628
+
629
+ var newMessage = _objectSpread$7(_objectSpread$7({}, message), {}, {
630
+ poll: updatedPoll
631
+ });
632
+
633
+ _this.addMessageSorted(newMessage, false, false);
634
+ });
635
+
531
636
  _defineProperty__default['default'](this, "updateUserMessages", function (user) {
532
637
  var _updateUserMessages = function _updateUserMessages(messages, user) {
533
638
  for (var i = 0; i < messages.length; i++) {
@@ -3632,6 +3737,69 @@ var Channel = /*#__PURE__*/function () {
3632
3737
 
3633
3738
  return createCall;
3634
3739
  }()
3740
+ /**
3741
+ * Cast or cancel one or more votes on a poll
3742
+ * @param pollId string The poll id
3743
+ * @param votes PollVoteData[] The votes that will be casted (or canceled in case of an empty array)
3744
+ * @returns {APIResponse & PollVoteResponse} The poll votes
3745
+ */
3746
+
3747
+ }, {
3748
+ key: "vote",
3749
+ value: function () {
3750
+ var _vote2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee40(messageId, pollId, _vote) {
3751
+ return _regeneratorRuntime__default['default'].wrap(function _callee40$(_context40) {
3752
+ while (1) {
3753
+ switch (_context40.prev = _context40.next) {
3754
+ case 0:
3755
+ _context40.next = 2;
3756
+ return this.getClient().castPollVote(messageId, pollId, _vote);
3757
+
3758
+ case 2:
3759
+ return _context40.abrupt("return", _context40.sent);
3760
+
3761
+ case 3:
3762
+ case "end":
3763
+ return _context40.stop();
3764
+ }
3765
+ }
3766
+ }, _callee40, this);
3767
+ }));
3768
+
3769
+ function vote(_x42, _x43, _x44) {
3770
+ return _vote2.apply(this, arguments);
3771
+ }
3772
+
3773
+ return vote;
3774
+ }()
3775
+ }, {
3776
+ key: "removeVote",
3777
+ value: function () {
3778
+ var _removeVote = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee41(messageId, pollId, voteId) {
3779
+ return _regeneratorRuntime__default['default'].wrap(function _callee41$(_context41) {
3780
+ while (1) {
3781
+ switch (_context41.prev = _context41.next) {
3782
+ case 0:
3783
+ _context41.next = 2;
3784
+ return this.getClient().removePollVote(messageId, pollId, voteId);
3785
+
3786
+ case 2:
3787
+ return _context41.abrupt("return", _context41.sent);
3788
+
3789
+ case 3:
3790
+ case "end":
3791
+ return _context41.stop();
3792
+ }
3793
+ }
3794
+ }, _callee41, this);
3795
+ }));
3796
+
3797
+ function removeVote(_x45, _x46, _x47) {
3798
+ return _removeVote.apply(this, arguments);
3799
+ }
3800
+
3801
+ return removeVote;
3802
+ }()
3635
3803
  /**
3636
3804
  * on - Listen to events on this channel.
3637
3805
  *
@@ -3930,6 +4098,49 @@ var Channel = /*#__PURE__*/function () {
3930
4098
 
3931
4099
  break;
3932
4100
 
4101
+ case 'poll.updated':
4102
+ if (event.poll) {
4103
+ var _event$message;
4104
+
4105
+ channelState.updatePoll(event.poll, ((_event$message = event.message) === null || _event$message === void 0 ? void 0 : _event$message.id) || '');
4106
+ }
4107
+
4108
+ break;
4109
+
4110
+ case 'poll.vote_casted':
4111
+ if (event.poll_vote && event.poll) {
4112
+ var _event$message2;
4113
+
4114
+ channelState.addPollVote(event.poll_vote, event.poll, ((_event$message2 = event.message) === null || _event$message2 === void 0 ? void 0 : _event$message2.id) || '');
4115
+ }
4116
+
4117
+ break;
4118
+
4119
+ case 'poll.vote_changed':
4120
+ if (event.poll_vote && event.poll) {
4121
+ var _event$message3;
4122
+
4123
+ channelState.updatePollVote(event.poll_vote, event.poll, ((_event$message3 = event.message) === null || _event$message3 === void 0 ? void 0 : _event$message3.id) || '');
4124
+ }
4125
+
4126
+ break;
4127
+
4128
+ case 'poll.vote_removed':
4129
+ if (event.poll_vote && event.poll) {
4130
+ var _event$message4;
4131
+
4132
+ channelState.removePollVote(event.poll_vote, event.poll, ((_event$message4 = event.message) === null || _event$message4 === void 0 ? void 0 : _event$message4.id) || '');
4133
+ }
4134
+
4135
+ break;
4136
+
4137
+ case 'poll.closed':
4138
+ if (event.message) {
4139
+ channelState.addMessageSorted(event.message, false, false);
4140
+ }
4141
+
4142
+ break;
4143
+
3933
4144
  case 'reaction.new':
3934
4145
  if (event.message && event.reaction) {
3935
4146
  event.message = channelState.addReaction(event.reaction, event.message);
@@ -6611,8 +6822,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
6611
6822
  DeleteUserOptions specifies a collection of one or more `user_ids` to be deleted.
6612
6823
 
6613
6824
  `user`:
6614
- - soft: marks user as deleted and retains all user data
6615
- - pruning: marks user as deleted and nullifies user information
6825
+ - soft: marks user as deleted and retains all user data
6826
+ - pruning: marks user as deleted and nullifies user information
6616
6827
  - hard: deletes user completely - this requires hard option for messages and conversation as well
6617
6828
  `conversations`:
6618
6829
  - soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled)
@@ -6651,6 +6862,14 @@ var ErrorFromResponse = /*#__PURE__*/function (_Error) {
6651
6862
 
6652
6863
  return ErrorFromResponse;
6653
6864
  }( /*#__PURE__*/_wrapNativeSuper__default['default'](Error));
6865
+ exports.VotingVisibility = void 0;
6866
+
6867
+ (function (VotingVisibility) {
6868
+ VotingVisibility["anonymous"] = "anonymous";
6869
+ VotingVisibility["public"] = "public";
6870
+ })(exports.VotingVisibility || (exports.VotingVisibility = {}));
6871
+
6872
+ var _excluded$1 = ["parent_message_id", "parent_message", "latest_replies", "thread_participants", "reply_count", "channel", "read"];
6654
6873
 
6655
6874
  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; }
6656
6875
 
@@ -6662,6 +6881,7 @@ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o
6662
6881
 
6663
6882
  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; }
6664
6883
  var Thread = /*#__PURE__*/function () {
6884
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6665
6885
  function Thread(client, t) {
6666
6886
  _classCallCheck__default['default'](this, Thread);
6667
6887
 
@@ -6683,17 +6903,28 @@ var Thread = /*#__PURE__*/function () {
6683
6903
 
6684
6904
  _defineProperty__default['default'](this, "read", {});
6685
6905
 
6686
- this.id = t.parent_message.id;
6687
- this.message = formatMessage(t.parent_message);
6688
- this.latestReplies = t.latest_replies.map(formatMessage);
6689
- this.participants = t.thread_participants;
6690
- this.replyCount = t.reply_count;
6691
- this.channel = t.channel;
6906
+ _defineProperty__default['default'](this, "data", {});
6907
+
6908
+ var parent_message_id = t.parent_message_id,
6909
+ parent_message = t.parent_message,
6910
+ latest_replies = t.latest_replies,
6911
+ thread_participants = t.thread_participants,
6912
+ reply_count = t.reply_count,
6913
+ channel = t.channel,
6914
+ read = t.read,
6915
+ data = _objectWithoutProperties__default['default'](t, _excluded$1);
6916
+
6917
+ this.id = parent_message_id;
6918
+ this.message = formatMessage(parent_message);
6919
+ this.latestReplies = latest_replies.map(formatMessage);
6920
+ this.participants = thread_participants;
6921
+ this.replyCount = reply_count;
6922
+ this.channel = channel;
6692
6923
  this._channel = client.channel(t.channel.type, t.channel.id);
6693
6924
  this._client = client;
6694
6925
 
6695
- if (t.read) {
6696
- var _iterator = _createForOfIteratorHelper$1(t.read),
6926
+ if (read) {
6927
+ var _iterator = _createForOfIteratorHelper$1(read),
6697
6928
  _step;
6698
6929
 
6699
6930
  try {
@@ -6709,6 +6940,8 @@ var Thread = /*#__PURE__*/function () {
6709
6940
  _iterator.f();
6710
6941
  }
6711
6942
  }
6943
+
6944
+ this.data = data;
6712
6945
  }
6713
6946
 
6714
6947
  _createClass__default['default'](Thread, [{
@@ -11125,7 +11358,7 @@ var StreamChat = /*#__PURE__*/function () {
11125
11358
  }, {
11126
11359
  key: "getUserAgent",
11127
11360
  value: function getUserAgent() {
11128
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.25.1");
11361
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.26.0");
11129
11362
  }
11130
11363
  }, {
11131
11364
  key: "setUserAgent",
@@ -12567,6 +12800,552 @@ var StreamChat = /*#__PURE__*/function () {
12567
12800
 
12568
12801
  return commitMessage;
12569
12802
  }()
12803
+ /**
12804
+ * Creates a poll
12805
+ * @param params PollData The poll that will be created
12806
+ * @returns {APIResponse & CreatePollAPIResponse} The poll
12807
+ */
12808
+
12809
+ }, {
12810
+ key: "createPoll",
12811
+ value: function () {
12812
+ var _createPoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee94(poll) {
12813
+ return _regeneratorRuntime__default['default'].wrap(function _callee94$(_context94) {
12814
+ while (1) {
12815
+ switch (_context94.prev = _context94.next) {
12816
+ case 0:
12817
+ _context94.next = 2;
12818
+ return this.post(this.baseURL + "/polls", poll);
12819
+
12820
+ case 2:
12821
+ return _context94.abrupt("return", _context94.sent);
12822
+
12823
+ case 3:
12824
+ case "end":
12825
+ return _context94.stop();
12826
+ }
12827
+ }
12828
+ }, _callee94, this);
12829
+ }));
12830
+
12831
+ function createPoll(_x129) {
12832
+ return _createPoll.apply(this, arguments);
12833
+ }
12834
+
12835
+ return createPoll;
12836
+ }()
12837
+ /**
12838
+ * Retrieves a poll
12839
+ * @param id string The poll id
12840
+ * @returns {APIResponse & GetPollAPIResponse} The poll
12841
+ */
12842
+
12843
+ }, {
12844
+ key: "getPoll",
12845
+ value: function () {
12846
+ var _getPoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee95(id, userId) {
12847
+ return _regeneratorRuntime__default['default'].wrap(function _callee95$(_context95) {
12848
+ while (1) {
12849
+ switch (_context95.prev = _context95.next) {
12850
+ case 0:
12851
+ _context95.next = 2;
12852
+ return this.get(this.baseURL + "/polls/".concat(id), _objectSpread({}, userId ? {
12853
+ user_id: userId
12854
+ } : {}));
12855
+
12856
+ case 2:
12857
+ return _context95.abrupt("return", _context95.sent);
12858
+
12859
+ case 3:
12860
+ case "end":
12861
+ return _context95.stop();
12862
+ }
12863
+ }
12864
+ }, _callee95, this);
12865
+ }));
12866
+
12867
+ function getPoll(_x130, _x131) {
12868
+ return _getPoll.apply(this, arguments);
12869
+ }
12870
+
12871
+ return getPoll;
12872
+ }()
12873
+ /**
12874
+ * Updates a poll
12875
+ * @param poll PollData The poll that will be updated
12876
+ * @returns {APIResponse & PollResponse} The poll
12877
+ */
12878
+
12879
+ }, {
12880
+ key: "updatePoll",
12881
+ value: function () {
12882
+ var _updatePoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee96(poll) {
12883
+ return _regeneratorRuntime__default['default'].wrap(function _callee96$(_context96) {
12884
+ while (1) {
12885
+ switch (_context96.prev = _context96.next) {
12886
+ case 0:
12887
+ _context96.next = 2;
12888
+ return this.put(this.baseURL + "/polls", poll);
12889
+
12890
+ case 2:
12891
+ return _context96.abrupt("return", _context96.sent);
12892
+
12893
+ case 3:
12894
+ case "end":
12895
+ return _context96.stop();
12896
+ }
12897
+ }
12898
+ }, _callee96, this);
12899
+ }));
12900
+
12901
+ function updatePoll(_x132) {
12902
+ return _updatePoll.apply(this, arguments);
12903
+ }
12904
+
12905
+ return updatePoll;
12906
+ }()
12907
+ /**
12908
+ * Partially updates a poll
12909
+ * @param id string The poll id
12910
+ * @param {PartialPollUpdate<StreamChatGenerics>} partialPollObject which should contain id and any of "set" or "unset" params;
12911
+ * example: {id: "44f26af5-f2be-4fa7-9dac-71cf893781de", set:{field: value}, unset:["field2"]}
12912
+ * @returns {APIResponse & UpdatePollAPIResponse} The poll
12913
+ */
12914
+
12915
+ }, {
12916
+ key: "partialUpdatePoll",
12917
+ value: function () {
12918
+ var _partialUpdatePoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee97(id, partialPollObject) {
12919
+ return _regeneratorRuntime__default['default'].wrap(function _callee97$(_context97) {
12920
+ while (1) {
12921
+ switch (_context97.prev = _context97.next) {
12922
+ case 0:
12923
+ _context97.next = 2;
12924
+ return this.patch(this.baseURL + "/polls/".concat(id), partialPollObject);
12925
+
12926
+ case 2:
12927
+ return _context97.abrupt("return", _context97.sent);
12928
+
12929
+ case 3:
12930
+ case "end":
12931
+ return _context97.stop();
12932
+ }
12933
+ }
12934
+ }, _callee97, this);
12935
+ }));
12936
+
12937
+ function partialUpdatePoll(_x133, _x134) {
12938
+ return _partialUpdatePoll.apply(this, arguments);
12939
+ }
12940
+
12941
+ return partialUpdatePoll;
12942
+ }()
12943
+ /**
12944
+ * Delete a poll
12945
+ * @param id string The poll id
12946
+ * @param userId string The user id (only serverside)
12947
+ * @returns
12948
+ */
12949
+
12950
+ }, {
12951
+ key: "deletePoll",
12952
+ value: function () {
12953
+ var _deletePoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee98(id, userId) {
12954
+ return _regeneratorRuntime__default['default'].wrap(function _callee98$(_context98) {
12955
+ while (1) {
12956
+ switch (_context98.prev = _context98.next) {
12957
+ case 0:
12958
+ _context98.next = 2;
12959
+ return this.delete(this.baseURL + "/polls/".concat(id), _objectSpread({}, userId ? {
12960
+ user_id: userId
12961
+ } : {}));
12962
+
12963
+ case 2:
12964
+ return _context98.abrupt("return", _context98.sent);
12965
+
12966
+ case 3:
12967
+ case "end":
12968
+ return _context98.stop();
12969
+ }
12970
+ }
12971
+ }, _callee98, this);
12972
+ }));
12973
+
12974
+ function deletePoll(_x135, _x136) {
12975
+ return _deletePoll.apply(this, arguments);
12976
+ }
12977
+
12978
+ return deletePoll;
12979
+ }()
12980
+ /**
12981
+ * Close a poll
12982
+ * @param id string The poll id
12983
+ * @returns {APIResponse & UpdatePollAPIResponse} The poll
12984
+ */
12985
+
12986
+ }, {
12987
+ key: "closePoll",
12988
+ value: function () {
12989
+ var _closePoll = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee99(id) {
12990
+ return _regeneratorRuntime__default['default'].wrap(function _callee99$(_context99) {
12991
+ while (1) {
12992
+ switch (_context99.prev = _context99.next) {
12993
+ case 0:
12994
+ return _context99.abrupt("return", this.partialUpdatePoll(id, {
12995
+ set: {
12996
+ is_closed: true
12997
+ }
12998
+ }));
12999
+
13000
+ case 1:
13001
+ case "end":
13002
+ return _context99.stop();
13003
+ }
13004
+ }
13005
+ }, _callee99, this);
13006
+ }));
13007
+
13008
+ function closePoll(_x137) {
13009
+ return _closePoll.apply(this, arguments);
13010
+ }
13011
+
13012
+ return closePoll;
13013
+ }()
13014
+ /**
13015
+ * Creates a poll option
13016
+ * @param pollId string The poll id
13017
+ * @param option PollOptionData The poll option that will be created
13018
+ * @returns {APIResponse & PollOptionResponse} The poll option
13019
+ */
13020
+
13021
+ }, {
13022
+ key: "createPollOption",
13023
+ value: function () {
13024
+ var _createPollOption = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee100(pollId, option) {
13025
+ return _regeneratorRuntime__default['default'].wrap(function _callee100$(_context100) {
13026
+ while (1) {
13027
+ switch (_context100.prev = _context100.next) {
13028
+ case 0:
13029
+ _context100.next = 2;
13030
+ return this.post(this.baseURL + "/polls/".concat(pollId, "/options"), option);
13031
+
13032
+ case 2:
13033
+ return _context100.abrupt("return", _context100.sent);
13034
+
13035
+ case 3:
13036
+ case "end":
13037
+ return _context100.stop();
13038
+ }
13039
+ }
13040
+ }, _callee100, this);
13041
+ }));
13042
+
13043
+ function createPollOption(_x138, _x139) {
13044
+ return _createPollOption.apply(this, arguments);
13045
+ }
13046
+
13047
+ return createPollOption;
13048
+ }()
13049
+ /**
13050
+ * Retrieves a poll option
13051
+ * @param pollId string The poll id
13052
+ * @param optionId string The poll option id
13053
+ * @returns {APIResponse & PollOptionResponse} The poll option
13054
+ */
13055
+
13056
+ }, {
13057
+ key: "getPollOption",
13058
+ value: function () {
13059
+ var _getPollOption = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee101(pollId, optionId) {
13060
+ return _regeneratorRuntime__default['default'].wrap(function _callee101$(_context101) {
13061
+ while (1) {
13062
+ switch (_context101.prev = _context101.next) {
13063
+ case 0:
13064
+ _context101.next = 2;
13065
+ return this.get(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId));
13066
+
13067
+ case 2:
13068
+ return _context101.abrupt("return", _context101.sent);
13069
+
13070
+ case 3:
13071
+ case "end":
13072
+ return _context101.stop();
13073
+ }
13074
+ }
13075
+ }, _callee101, this);
13076
+ }));
13077
+
13078
+ function getPollOption(_x140, _x141) {
13079
+ return _getPollOption.apply(this, arguments);
13080
+ }
13081
+
13082
+ return getPollOption;
13083
+ }()
13084
+ /**
13085
+ * Updates a poll option
13086
+ * @param pollId string The poll id
13087
+ * @param option PollOptionData The poll option that will be updated
13088
+ * @returns
13089
+ */
13090
+
13091
+ }, {
13092
+ key: "updatePollOption",
13093
+ value: function () {
13094
+ var _updatePollOption = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee102(pollId, option) {
13095
+ return _regeneratorRuntime__default['default'].wrap(function _callee102$(_context102) {
13096
+ while (1) {
13097
+ switch (_context102.prev = _context102.next) {
13098
+ case 0:
13099
+ _context102.next = 2;
13100
+ return this.put(this.baseURL + "/polls/".concat(pollId, "/options"), option);
13101
+
13102
+ case 2:
13103
+ return _context102.abrupt("return", _context102.sent);
13104
+
13105
+ case 3:
13106
+ case "end":
13107
+ return _context102.stop();
13108
+ }
13109
+ }
13110
+ }, _callee102, this);
13111
+ }));
13112
+
13113
+ function updatePollOption(_x142, _x143) {
13114
+ return _updatePollOption.apply(this, arguments);
13115
+ }
13116
+
13117
+ return updatePollOption;
13118
+ }()
13119
+ /**
13120
+ * Delete a poll option
13121
+ * @param pollId string The poll id
13122
+ * @param optionId string The poll option id
13123
+ * @returns {APIResponse} The poll option
13124
+ */
13125
+
13126
+ }, {
13127
+ key: "deletePollOption",
13128
+ value: function () {
13129
+ var _deletePollOption = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee103(pollId, optionId) {
13130
+ return _regeneratorRuntime__default['default'].wrap(function _callee103$(_context103) {
13131
+ while (1) {
13132
+ switch (_context103.prev = _context103.next) {
13133
+ case 0:
13134
+ _context103.next = 2;
13135
+ return this.delete(this.baseURL + "/polls/".concat(pollId, "/options/").concat(optionId));
13136
+
13137
+ case 2:
13138
+ return _context103.abrupt("return", _context103.sent);
13139
+
13140
+ case 3:
13141
+ case "end":
13142
+ return _context103.stop();
13143
+ }
13144
+ }
13145
+ }, _callee103, this);
13146
+ }));
13147
+
13148
+ function deletePollOption(_x144, _x145) {
13149
+ return _deletePollOption.apply(this, arguments);
13150
+ }
13151
+
13152
+ return deletePollOption;
13153
+ }()
13154
+ /**
13155
+ * Cast vote on a poll
13156
+ * @param messageId string The message id
13157
+ * @param pollId string The poll id
13158
+ * @param vote PollVoteData The vote that will be casted
13159
+ * @returns {APIResponse & CastVoteAPIResponse} The poll vote
13160
+ */
13161
+
13162
+ }, {
13163
+ key: "castPollVote",
13164
+ value: function () {
13165
+ var _castPollVote = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee104(messageId, pollId, vote) {
13166
+ var options,
13167
+ _args104 = arguments;
13168
+ return _regeneratorRuntime__default['default'].wrap(function _callee104$(_context104) {
13169
+ while (1) {
13170
+ switch (_context104.prev = _context104.next) {
13171
+ case 0:
13172
+ options = _args104.length > 3 && _args104[3] !== undefined ? _args104[3] : {};
13173
+ _context104.next = 3;
13174
+ return this.post(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote"), _objectSpread({
13175
+ vote: vote
13176
+ }, options));
13177
+
13178
+ case 3:
13179
+ return _context104.abrupt("return", _context104.sent);
13180
+
13181
+ case 4:
13182
+ case "end":
13183
+ return _context104.stop();
13184
+ }
13185
+ }
13186
+ }, _callee104, this);
13187
+ }));
13188
+
13189
+ function castPollVote(_x146, _x147, _x148) {
13190
+ return _castPollVote.apply(this, arguments);
13191
+ }
13192
+
13193
+ return castPollVote;
13194
+ }()
13195
+ /**
13196
+ * Add a poll answer
13197
+ * @param messageId string The message id
13198
+ * @param pollId string The poll id
13199
+ * @param answerText string The answer text
13200
+ */
13201
+
13202
+ }, {
13203
+ key: "addPollAnswer",
13204
+ value: function () {
13205
+ var _addPollAnswer = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee105(messageId, pollId, answerText) {
13206
+ return _regeneratorRuntime__default['default'].wrap(function _callee105$(_context105) {
13207
+ while (1) {
13208
+ switch (_context105.prev = _context105.next) {
13209
+ case 0:
13210
+ return _context105.abrupt("return", this.castPollVote(messageId, pollId, {
13211
+ answer_text: answerText
13212
+ }));
13213
+
13214
+ case 1:
13215
+ case "end":
13216
+ return _context105.stop();
13217
+ }
13218
+ }
13219
+ }, _callee105, this);
13220
+ }));
13221
+
13222
+ function addPollAnswer(_x149, _x150, _x151) {
13223
+ return _addPollAnswer.apply(this, arguments);
13224
+ }
13225
+
13226
+ return addPollAnswer;
13227
+ }()
13228
+ }, {
13229
+ key: "removePollVote",
13230
+ value: function () {
13231
+ var _removePollVote = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee106(messageId, pollId, voteId) {
13232
+ return _regeneratorRuntime__default['default'].wrap(function _callee106$(_context106) {
13233
+ while (1) {
13234
+ switch (_context106.prev = _context106.next) {
13235
+ case 0:
13236
+ _context106.next = 2;
13237
+ return this.delete(this.baseURL + "/messages/".concat(messageId, "/polls/").concat(pollId, "/vote/").concat(voteId));
13238
+
13239
+ case 2:
13240
+ return _context106.abrupt("return", _context106.sent);
13241
+
13242
+ case 3:
13243
+ case "end":
13244
+ return _context106.stop();
13245
+ }
13246
+ }
13247
+ }, _callee106, this);
13248
+ }));
13249
+
13250
+ function removePollVote(_x152, _x153, _x154) {
13251
+ return _removePollVote.apply(this, arguments);
13252
+ }
13253
+
13254
+ return removePollVote;
13255
+ }()
13256
+ /**
13257
+ * Queries polls
13258
+ * @param filter
13259
+ * @param sort
13260
+ * @param options Option object, {limit: 10, offset:0}
13261
+ * @returns {APIResponse & QueryPollsResponse} The polls
13262
+ */
13263
+
13264
+ }, {
13265
+ key: "queryPolls",
13266
+ value: function () {
13267
+ var _queryPolls = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee107() {
13268
+ var filter,
13269
+ sort,
13270
+ options,
13271
+ _args107 = arguments;
13272
+ return _regeneratorRuntime__default['default'].wrap(function _callee107$(_context107) {
13273
+ while (1) {
13274
+ switch (_context107.prev = _context107.next) {
13275
+ case 0:
13276
+ filter = _args107.length > 0 && _args107[0] !== undefined ? _args107[0] : {};
13277
+ sort = _args107.length > 1 && _args107[1] !== undefined ? _args107[1] : [];
13278
+ options = _args107.length > 2 && _args107[2] !== undefined ? _args107[2] : {};
13279
+ _context107.next = 5;
13280
+ return this.post(this.baseURL + '/polls/query', _objectSpread({
13281
+ filter: filter,
13282
+ sort: normalizeQuerySort(sort)
13283
+ }, options));
13284
+
13285
+ case 5:
13286
+ return _context107.abrupt("return", _context107.sent);
13287
+
13288
+ case 6:
13289
+ case "end":
13290
+ return _context107.stop();
13291
+ }
13292
+ }
13293
+ }, _callee107, this);
13294
+ }));
13295
+
13296
+ function queryPolls() {
13297
+ return _queryPolls.apply(this, arguments);
13298
+ }
13299
+
13300
+ return queryPolls;
13301
+ }()
13302
+ /**
13303
+ * Queries poll votes
13304
+ * @param pollId
13305
+ * @param filter
13306
+ * @param sort
13307
+ * @param options Option object, {limit: 10, offset:0}
13308
+ * @returns {APIResponse & PollVotesAPIResponse} The poll votes
13309
+ */
13310
+
13311
+ }, {
13312
+ key: "queryPollVotes",
13313
+ value: function () {
13314
+ var _queryPollVotes = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee108(pollId) {
13315
+ var filter,
13316
+ sort,
13317
+ options,
13318
+ _args108 = arguments;
13319
+ return _regeneratorRuntime__default['default'].wrap(function _callee108$(_context108) {
13320
+ while (1) {
13321
+ switch (_context108.prev = _context108.next) {
13322
+ case 0:
13323
+ filter = _args108.length > 1 && _args108[1] !== undefined ? _args108[1] : {};
13324
+ sort = _args108.length > 2 && _args108[2] !== undefined ? _args108[2] : [];
13325
+ options = _args108.length > 3 && _args108[3] !== undefined ? _args108[3] : {};
13326
+ _context108.next = 5;
13327
+ return this.post(this.baseURL + "/polls/".concat(pollId, "/votes"), _objectSpread({
13328
+ filter: filter,
13329
+ sort: normalizeQuerySort(sort)
13330
+ }, options));
13331
+
13332
+ case 5:
13333
+ return _context108.abrupt("return", _context108.sent);
13334
+
13335
+ case 6:
13336
+ case "end":
13337
+ return _context108.stop();
13338
+ }
13339
+ }
13340
+ }, _callee108, this);
13341
+ }));
13342
+
13343
+ function queryPollVotes(_x155) {
13344
+ return _queryPollVotes.apply(this, arguments);
13345
+ }
13346
+
13347
+ return queryPollVotes;
13348
+ }()
12570
13349
  }], [{
12571
13350
  key: "getInstance",
12572
13351
  value: function getInstance(key, secretOrOptions, options) {
@@ -12619,6 +13398,11 @@ var EVENT_MAP = {
12619
13398
  'notification.mutes_updated': true,
12620
13399
  'notification.removed_from_channel': true,
12621
13400
  'notification.thread_message_new': true,
13401
+ 'poll.closed': true,
13402
+ 'poll.updated': true,
13403
+ 'poll.vote_casted': true,
13404
+ 'poll.vote_changed': true,
13405
+ 'poll.vote_removed': true,
12622
13406
  'reaction.deleted': true,
12623
13407
  'reaction.new': true,
12624
13408
  'reaction.updated': true,