polfan-server-js-client 0.2.101 → 0.2.103

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.
@@ -4,10 +4,9 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Adjust session data changes">
8
- <change afterPath="$PROJECT_DIR$/src/types/src/schemes/commands/UnfollowTopic.ts" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/types" beforeDir="false" afterPath="$PROJECT_DIR$/src/types" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/src/types/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/src/index.ts" afterDir="false" />
7
+ <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Topic unfollowing">
8
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/WebApiChatClient.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/WebApiChatClient.ts" afterDir="false" />
11
10
  </list>
12
11
  <option name="SHOW_DIALOG" value="false" />
13
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -30,7 +29,7 @@
30
29
  <entry key="$PROJECT_DIR$/src/types" value="562c7beff95ea1eaf5c236df978f50a614a146af" />
31
30
  </map>
32
31
  </option>
33
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/src/types" />
32
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
34
33
  <option name="ROOT_SYNC" value="DONT_SYNC" />
35
34
  </component>
36
35
  <component name="GitHubPullRequestSearchHistory">{
@@ -71,7 +70,7 @@
71
70
  "RunOnceActivity.typescript.service.memoryLimit.init": "true",
72
71
  "codeWithMe.voiceChat.enabledByDefault": "false",
73
72
  "com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
74
- "git-widget-placeholder": "main",
73
+ "git-widget-placeholder": "master",
75
74
  "git.auto.fetch.suggestion.counter": "1",
76
75
  "ignore.virus.scanning.warn.message": "true",
77
76
  "junie.onboarding.icon.badge.shown": "true",
@@ -210,23 +209,7 @@
210
209
  <workItem from="1782664203095" duration="5539000" />
211
210
  <workItem from="1782909199211" duration="2404000" />
212
211
  <workItem from="1783939298935" duration="21428000" />
213
- <workItem from="1784102649250" duration="4695000" />
214
- </task>
215
- <task id="LOCAL-00052" summary="Changes in chat protocol and schemes">
216
- <option name="closed" value="true" />
217
- <created>1754249755333</created>
218
- <option name="number" value="00052" />
219
- <option name="presentableId" value="LOCAL-00052" />
220
- <option name="project" value="LOCAL" />
221
- <updated>1754249755333</updated>
222
- </task>
223
- <task id="LOCAL-00053" summary="New member count field in RoomSummary">
224
- <option name="closed" value="true" />
225
- <created>1754319172537</created>
226
- <option name="number" value="00053" />
227
- <option name="presentableId" value="LOCAL-00053" />
228
- <option name="project" value="LOCAL" />
229
- <updated>1754319172537</updated>
212
+ <workItem from="1784102649250" duration="10048000" />
230
213
  </task>
231
214
  <task id="LOCAL-00054" summary="Version bump">
232
215
  <option name="closed" value="true" />
@@ -604,7 +587,23 @@
604
587
  <option name="project" value="LOCAL" />
605
588
  <updated>1784225321435</updated>
606
589
  </task>
607
- <option name="localTasksCounter" value="101" />
590
+ <task id="LOCAL-00101" summary="Topic unfollowing">
591
+ <option name="closed" value="true" />
592
+ <created>1784229730189</created>
593
+ <option name="number" value="00101" />
594
+ <option name="presentableId" value="LOCAL-00101" />
595
+ <option name="project" value="LOCAL" />
596
+ <updated>1784229730189</updated>
597
+ </task>
598
+ <task id="LOCAL-00102" summary="Topic unfollowing">
599
+ <option name="closed" value="true" />
600
+ <created>1784236719408</created>
601
+ <option name="number" value="00102" />
602
+ <option name="presentableId" value="LOCAL-00102" />
603
+ <option name="project" value="LOCAL" />
604
+ <updated>1784236719408</updated>
605
+ </task>
606
+ <option name="localTasksCounter" value="103" />
608
607
  <servers />
609
608
  </component>
610
609
  <component name="TypeScriptGeneratedFilesManager">
@@ -649,7 +648,6 @@
649
648
  </option>
650
649
  </component>
651
650
  <component name="VcsManagerConfiguration">
652
- <MESSAGE value="Fix URL parameter handling in GET and DELETE requests" />
653
651
  <MESSAGE value="Improve hasOldest behavior when resetToLatest used" />
654
652
  <MESSAGE value="Align permissions to server changes" />
655
653
  <MESSAGE value="Allow to define ManageRoom permission on room level" />
@@ -674,7 +672,8 @@
674
672
  <MESSAGE value="Adjust method names" />
675
673
  <MESSAGE value="Fix roles checking in spaceless rooms" />
676
674
  <MESSAGE value="Adjust session data changes" />
677
- <option name="LAST_COMMIT_MESSAGE" value="Adjust session data changes" />
675
+ <MESSAGE value="Topic unfollowing" />
676
+ <option name="LAST_COMMIT_MESSAGE" value="Topic unfollowing" />
678
677
  </component>
679
678
  <component name="XSLT-Support.FileAssociations.UIState">
680
679
  <expand />
@@ -1906,6 +1906,9 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
1906
1906
  _this.tracker.client.on('TopicFollowed', function (ev) {
1907
1907
  return _this.handleTopicFollowed(ev);
1908
1908
  });
1909
+ _this.tracker.client.on('TopicUnfollowed', function (ev) {
1910
+ return _this.handleTopicUnfollowed(ev);
1911
+ });
1909
1912
  _this.tracker.client.on('NewMessage', function (ev) {
1910
1913
  return _this.handleNewMessage(ev);
1911
1914
  });
@@ -2345,6 +2348,13 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2345
2348
  this.setFollowedTopicsArray([ev.followedTopic.location.roomId], [ev.followedTopic]);
2346
2349
  this.invalidateUnreadSummaries(ev.followedTopic.location.roomId, ev.followedTopic.location.topicId);
2347
2350
  }
2351
+ }, {
2352
+ key: "handleTopicUnfollowed",
2353
+ value: function handleTopicUnfollowed(ev) {
2354
+ var _this$followedTopics$3;
2355
+ (_this$followedTopics$3 = this.followedTopics.get(ev.location.roomId)) === null || _this$followedTopics$3 === void 0 || _this$followedTopics$3["delete"](ev.location.topicId);
2356
+ this.invalidateUnreadSummaries(ev.location.roomId, ev.location.topicId);
2357
+ }
2348
2358
  }, {
2349
2359
  key: "handleRoomDeleted",
2350
2360
  value: function handleRoomDeleted(ev) {
@@ -2399,8 +2409,8 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2399
2409
  }, {
2400
2410
  key: "handleTopicDeleted",
2401
2411
  value: function handleTopicDeleted(ev) {
2402
- var _this$followedTopics$3;
2403
- (_this$followedTopics$3 = this.followedTopics.get(ev.location.roomId)) === null || _this$followedTopics$3 === void 0 || _this$followedTopics$3["delete"](ev.location.topicId);
2412
+ var _this$followedTopics$4;
2413
+ (_this$followedTopics$4 = this.followedTopics.get(ev.location.roomId)) === null || _this$followedTopics$4 === void 0 || _this$followedTopics$4["delete"](ev.location.topicId);
2404
2414
  this.invalidateUnreadSummaries(ev.location.roomId, ev.location.topicId);
2405
2415
  }
2406
2416
 
@@ -5218,7 +5228,7 @@ var WebApiChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5218
5228
  WebApiChatClient_classCallCheck(this, WebApiChatClient);
5219
5229
  _this = WebApiChatClient_callSuper(this, WebApiChatClient);
5220
5230
  WebApiChatClient_defineProperty(_this, "Event", WebApiChatClientEvent);
5221
- WebApiChatClient_defineProperty(_this, "sendStack", void 0);
5231
+ WebApiChatClient_defineProperty(_this, "sendStack", []);
5222
5232
  _this.options = options;
5223
5233
  return _this;
5224
5234
  }
@@ -5227,17 +5237,18 @@ var WebApiChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5227
5237
  key: "send",
5228
5238
  value: function () {
5229
5239
  var _send = WebApiChatClient_asyncToGenerator(/*#__PURE__*/WebApiChatClient_regenerator().m(function _callee(commandType, commandData) {
5230
- var envelope;
5240
+ var envelope, item;
5231
5241
  return WebApiChatClient_regenerator().w(function (_context) {
5232
5242
  while (1) switch (_context.n) {
5233
5243
  case 0:
5234
5244
  envelope = this.createEnvelope(commandType, commandData);
5235
- this.sendStack.push({
5245
+ item = {
5236
5246
  data: envelope,
5237
5247
  attempts: 0,
5238
5248
  lastTimeoutId: null
5239
- });
5240
- this.makeApiCall(this.sendStack.length - 1);
5249
+ };
5250
+ this.sendStack.push(item);
5251
+ this.makeApiCall(item);
5241
5252
  return _context.a(2, this.createPromiseFromCommandEnvelope(envelope));
5242
5253
  }
5243
5254
  }, _callee, this);
@@ -5251,36 +5262,53 @@ var WebApiChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5251
5262
  key: "destroy",
5252
5263
  value: function destroy() {
5253
5264
  var _this2 = this;
5254
- // Cancel all awaiting requests
5255
- this.sendStack.forEach(function (item) {
5265
+ // Cancel all awaiting requests, rejecting their promises so no caller
5266
+ // is left awaiting forever
5267
+ var pending = this.sendStack;
5268
+ this.sendStack = [];
5269
+ pending.forEach(function (item) {
5256
5270
  if (item.lastTimeoutId) {
5257
5271
  clearTimeout(item.lastTimeoutId);
5258
5272
  }
5259
- _this2.awaitingResponse["delete"](item.data.ref);
5273
+ _this2.handleEnvelopeSendError(item.data, new Error('Client destroyed'));
5260
5274
  });
5261
- this.sendStack = [];
5262
5275
  this.emit(this.Event.destroy, false);
5263
5276
  }
5264
5277
  }, {
5265
5278
  key: "onMessage",
5266
5279
  value: function () {
5267
- var _onMessage = WebApiChatClient_asyncToGenerator(/*#__PURE__*/WebApiChatClient_regenerator().m(function _callee2(reqId, response) {
5268
- var envelope;
5280
+ var _onMessage = WebApiChatClient_asyncToGenerator(/*#__PURE__*/WebApiChatClient_regenerator().m(function _callee2(item, response) {
5281
+ var envelope, _t;
5269
5282
  return WebApiChatClient_regenerator().w(function (_context2) {
5270
- while (1) switch (_context2.n) {
5283
+ while (1) switch (_context2.p = _context2.n) {
5271
5284
  case 0:
5272
- this.sendStack.splice(reqId, 1);
5285
+ _context2.p = 0;
5273
5286
  _context2.n = 1;
5274
5287
  return response.json();
5275
5288
  case 1:
5276
5289
  envelope = _context2.v;
5290
+ _context2.n = 3;
5291
+ break;
5292
+ case 2:
5293
+ _context2.p = 2;
5294
+ _t = _context2.v;
5295
+ // Non-envelope response (e.g. a proxy error page) - failed attempt
5296
+ this.onError(item, "envelope ".concat(item.data.ref, " (HTTP ").concat(response.status, ", unparsable body)"));
5297
+ return _context2.a(2);
5298
+ case 3:
5299
+ if (this.removeFromStack(item)) {
5300
+ _context2.n = 4;
5301
+ break;
5302
+ }
5303
+ return _context2.a(2);
5304
+ case 4:
5277
5305
  this.handleIncomingEnvelope(envelope);
5278
5306
  this.emit(envelope.type, envelope.data);
5279
5307
  this.emit(this.Event.message, envelope);
5280
- case 2:
5308
+ case 5:
5281
5309
  return _context2.a(2);
5282
5310
  }
5283
- }, _callee2, this);
5311
+ }, _callee2, this, [[0, 2]]);
5284
5312
  }));
5285
5313
  function onMessage(_x3, _x4) {
5286
5314
  return _onMessage.apply(this, arguments);
@@ -5289,43 +5317,60 @@ var WebApiChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5289
5317
  }()
5290
5318
  }, {
5291
5319
  key: "onError",
5292
- value: function onError(reqId, body) {
5320
+ value: function onError(item, body) {
5293
5321
  var _this$options$attempt,
5294
5322
  _this3 = this,
5295
5323
  _this$options$attempt2;
5296
- if (this.sendStack[reqId].attempts >= ((_this$options$attempt = this.options.attemptsToSend) !== null && _this$options$attempt !== void 0 ? _this$options$attempt : 10)) {
5297
- this.sendStack.splice(reqId, 1);
5298
- this.handleEnvelopeSendError(this.sendStack[reqId].data, new Error("Cannot send ".concat(body, "; aborting after reaching the maximum connection errors")));
5324
+ if (!this.sendStack.includes(item)) {
5325
+ return; // Destroyed in the meantime
5326
+ }
5327
+ if (item.attempts >= ((_this$options$attempt = this.options.attemptsToSend) !== null && _this$options$attempt !== void 0 ? _this$options$attempt : 10)) {
5328
+ this.removeFromStack(item);
5329
+ this.handleEnvelopeSendError(item.data, new Error("Cannot send ".concat(body, "; aborting after reaching the maximum connection errors")));
5299
5330
  return;
5300
5331
  }
5301
- this.sendStack[reqId].lastTimeoutId = setTimeout(function () {
5302
- return _this3.makeApiCall(reqId);
5332
+ item.lastTimeoutId = setTimeout(function () {
5333
+ return _this3.makeApiCall(item);
5303
5334
  }, (_this$options$attempt2 = this.options.attemptDelayMs) !== null && _this$options$attempt2 !== void 0 ? _this$options$attempt2 : 3000);
5304
5335
  }
5305
5336
  }, {
5306
5337
  key: "makeApiCall",
5307
- value: function makeApiCall(reqId) {
5338
+ value: function makeApiCall(item) {
5308
5339
  var _this$options$queryPa,
5309
5340
  _this4 = this;
5310
- this.sendStack[reqId].attempts++;
5311
- var bodyJson = JSON.stringify(this.sendStack[reqId].data);
5341
+ if (!this.sendStack.includes(item)) {
5342
+ return; // Destroyed before this (re)try fired
5343
+ }
5344
+ item.attempts++;
5345
+ item.lastTimeoutId = null;
5346
+ var bodyJson = JSON.stringify(item.data);
5312
5347
  var headers = {
5313
5348
  'Content-Type': 'application/json',
5314
5349
  Accept: 'application/json'
5315
5350
  };
5316
5351
  headers.Authorization = "Bearer ".concat(this.options.token);
5317
- var params = new URLSearchParams((_this$options$queryPa = this.options.queryParams) !== null && _this$options$queryPa !== void 0 ? _this$options$queryPa : {});
5318
- var url = "".concat(this.options.url).concat(params ? '?' + params : '');
5352
+ var query = new URLSearchParams((_this$options$queryPa = this.options.queryParams) !== null && _this$options$queryPa !== void 0 ? _this$options$queryPa : {}).toString();
5353
+ var url = query ? "".concat(this.options.url, "?").concat(query) : this.options.url;
5319
5354
  fetch(url, {
5320
5355
  headers: headers,
5321
5356
  body: bodyJson,
5322
5357
  method: 'POST'
5323
5358
  }).then(function (response) {
5324
- return _this4.onMessage(reqId, response);
5359
+ return _this4.onMessage(item, response);
5325
5360
  })["catch"](function () {
5326
- return _this4.onError(reqId, bodyJson);
5361
+ return _this4.onError(item, bodyJson);
5327
5362
  });
5328
5363
  }
5364
+ }, {
5365
+ key: "removeFromStack",
5366
+ value: function removeFromStack(item) {
5367
+ var index = this.sendStack.indexOf(item);
5368
+ if (index === -1) {
5369
+ return false;
5370
+ }
5371
+ this.sendStack.splice(index, 1);
5372
+ return true;
5373
+ }
5329
5374
  }]);
5330
5375
  }(AbstractChatClient);
5331
5376
  ;// ./src/AbstractRestClient.ts